Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/assets/Hawk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion workers/email/src/templates/emails/event/html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
{% endblock %}

{% block unsubscribeLink %}
{{ host ~ '/unsubscribe/' ~ project._id }}
{{ host ~ '/unsubscribe/' ~ project._id ~ '/' ~ notificationRuleId }}
{% endblock %}

{% block unsubscribeText %}
Expand Down
2 changes: 2 additions & 0 deletions workers/email/tests/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('EmailProvider', () => {
period: 60,
host: process.env.GARAGE_URL!,
hostOfStatic: process.env.API_STATIC_URL!,
notificationRuleId: '5d206f7f9aaf7c0071d64596',
project: {
_id: new ObjectId('5d206f7f9aaf7c0071d64596'),
token: 'project-token',
Expand Down Expand Up @@ -131,6 +132,7 @@ describe('EmailProvider', () => {
}],
host: process.env.GARAGE_URL!,
hostOfStatic: process.env.API_STATIC_URL!,
notificationRuleId: '5d206f7f9aaf7c0071d64596',
project: {
_id: new ObjectId('5d206f7f9aaf7c0071d64596'),
token: 'project-token',
Expand Down
20 changes: 8 additions & 12 deletions workers/notifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Handles new events from Grouper Worker, holds it and sends to sender worlers

This repository is a part of the Hawk ecosystemm. You can register [here](https://garage.hawk.so/login)

![alt text](../../.github/assets/Hawk.png)


## How to run

1. Make sure you are in Workers root directory
Expand All @@ -12,21 +17,12 @@ Handles new events from Grouper Worker, holds it and sends to sender worlers
## Events handling scheme

```
1) On task received
-> receive task
-> get project notification rules
-> filter rules
-> check channel timer
a) if timer doesn't exist
-> send tasks to sender workers
-> set timeout for minPeriod
b) if timer exists
-> push event to channel's buffer

2) On timeout
-> get events from channel's buffer
-> flush channel's buffer
-> send tasks to sender workers
-> update eventsCount in redis
-> get updated eventCount
-> send notification if eventCount == treshold
```

### Event example
Expand Down
1 change: 1 addition & 0 deletions workers/sender/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export default abstract class SenderWorker extends Worker {
project,
events: eventsData,
period: channel.minPeriod,
notificationRuleId: rule._id,
},
} as EventNotification | SeveralEventsNotification);
}
Expand Down
6 changes: 6 additions & 0 deletions workers/sender/types/template-variables/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export interface EventsTemplateVariables extends CommonTemplateVariables {
* Minimal pause between second notification, in seconds
*/
period: number;

/**
* Id of notification rule to unsubscribe.
* Required for email notifications – to form unsubscribe link.
*/
notificationRuleId?: string;
}

/**
Expand Down
Loading