Skip to content

Commit e0a1166

Browse files
github-actions[bot]e11syTatianaFomina
authored
Update prod (#422)
* chore: update notifier readme (#421) * chore: update notifier readme * chore: typo * chore(notifier): add pic to readme * chore(notifer): rm redundant * chore: reorder * chore: rm redundant * fix(emails): Update unsubscribe link (#424) * Update link * Upd * Fix tests --------- Co-authored-by: e11sy <130844513+e11sy@users.noreply.github.com> Co-authored-by: Tatiana Fomina <fomina.tatianaaa@yandex.ru>
1 parent 6a92ed7 commit e0a1166

6 files changed

Lines changed: 18 additions & 13 deletions

File tree

.github/assets/Hawk.png

168 KB
Loading

workers/email/src/templates/emails/event/html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
{% endblock %}
5959

6060
{% block unsubscribeLink %}
61-
{{ host ~ '/unsubscribe/' ~ project._id }}
61+
{{ host ~ '/unsubscribe/' ~ project._id ~ '/' ~ notificationRuleId }}
6262
{% endblock %}
6363

6464
{% block unsubscribeText %}

workers/email/tests/provider.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe('EmailProvider', () => {
8181
period: 60,
8282
host: process.env.GARAGE_URL!,
8383
hostOfStatic: process.env.API_STATIC_URL!,
84+
notificationRuleId: '5d206f7f9aaf7c0071d64596',
8485
project: {
8586
_id: new ObjectId('5d206f7f9aaf7c0071d64596'),
8687
token: 'project-token',
@@ -131,6 +132,7 @@ describe('EmailProvider', () => {
131132
}],
132133
host: process.env.GARAGE_URL!,
133134
hostOfStatic: process.env.API_STATIC_URL!,
135+
notificationRuleId: '5d206f7f9aaf7c0071d64596',
134136
project: {
135137
_id: new ObjectId('5d206f7f9aaf7c0071d64596'),
136138
token: 'project-token',

workers/notifier/README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

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

5+
This repository is a part of the Hawk ecosystemm. You can register [here](https://garage.hawk.so/login)
6+
7+
![alt text](../../.github/assets/Hawk.png)
8+
9+
510
## How to run
611

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

1419
```
15-
1) On task received
1620
-> receive task
1721
-> get project notification rules
1822
-> filter rules
19-
-> check channel timer
20-
a) if timer doesn't exist
21-
-> send tasks to sender workers
22-
-> set timeout for minPeriod
23-
b) if timer exists
24-
-> push event to channel's buffer
25-
26-
2) On timeout
27-
-> get events from channel's buffer
28-
-> flush channel's buffer
29-
-> send tasks to sender workers
23+
-> update eventsCount in redis
24+
-> get updated eventCount
25+
-> send notification if eventCount == treshold
3026
```
3127

3228
### Event example

workers/sender/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export default abstract class SenderWorker extends Worker {
196196
project,
197197
events: eventsData,
198198
period: channel.minPeriod,
199+
notificationRuleId: rule._id,
199200
},
200201
} as EventNotification | SeveralEventsNotification);
201202
}

workers/sender/types/template-variables/event.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ export interface EventsTemplateVariables extends CommonTemplateVariables {
4545
* Minimal pause between second notification, in seconds
4646
*/
4747
period: number;
48+
49+
/**
50+
* Id of notification rule to unsubscribe.
51+
* Required for email notifications – to form unsubscribe link.
52+
*/
53+
notificationRuleId?: string;
4854
}
4955

5056
/**

0 commit comments

Comments
 (0)