Skip to content

Commit 4ca4e05

Browse files
Change copies of listed/unlisted notifications
related to Giveth/giveth-dapps-v2#2305 (comment)
1 parent c6f4dc0 commit 4ca4e05

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
3+
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';
4+
5+
export class changeNotificationCopies1692698983844
6+
implements MigrationInterface
7+
{
8+
private async updateNotificationType(
9+
eventName: string,
10+
data: {
11+
htmlTemplate?: any;
12+
content?: string;
13+
},
14+
) {
15+
const notificationType = await getNotificationTypeByEventName(eventName);
16+
if (!notificationType) {
17+
return;
18+
}
19+
notificationType.htmlTemplate = data.htmlTemplate;
20+
notificationType.content = data.content;
21+
await notificationType.save();
22+
}
23+
24+
public async up(queryRunner: QueryRunner): Promise<void> {
25+
const notificationTypesArray = [
26+
{
27+
eventName: NOTIFICATION_TYPE_NAMES.PROJECT_LISTED_OWNER,
28+
data: {
29+
content:
30+
'Your project {project name} has been listed on the projects page.',
31+
htmlTemplate: [
32+
{
33+
type: 'p',
34+
content: 'Your project ',
35+
},
36+
{
37+
type: 'a',
38+
content: '$projectTitle',
39+
href: '$projectLink',
40+
},
41+
{
42+
type: 'p',
43+
content: ' has been listed on the projects page.',
44+
},
45+
],
46+
},
47+
},
48+
{
49+
eventName: NOTIFICATION_TYPE_NAMES.PROJECT_UNLISTED_OWNER,
50+
data: {
51+
content:
52+
'Your project {project name} has been unlisted from the projects page.',
53+
htmlTemplate: [
54+
{
55+
type: 'p',
56+
content: 'Your project ',
57+
},
58+
{
59+
type: 'a',
60+
content: '$projectTitle',
61+
href: '$projectLink',
62+
},
63+
{
64+
type: 'p',
65+
content: ' has been unlisted from the projects page.',
66+
},
67+
],
68+
},
69+
},
70+
];
71+
await Promise.all(
72+
notificationTypesArray.map(item =>
73+
this.updateNotificationType(item.eventName, item.data),
74+
),
75+
);
76+
}
77+
78+
public async down(queryRunner: QueryRunner): Promise<void> {
79+
//
80+
}
81+
}

0 commit comments

Comments
 (0)