Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F 943 change cancelled project notification copies #53

Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.14.2
node-version: 18.14.0
- name: Install dependencies
run: npm ci
- name: Run linter
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.16.0
v18.14.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#https://hub.docker.com/_/node?tab=tags&page=1
FROM node:16.14.2-alpine3.15
FROM node:18.14.0

WORKDIR /usr/src/app

Expand Down
90 changes: 90 additions & 0 deletions migrations/1681206838965-changeCancelProjectNotificationCopies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { getNotificationTypeByEventName } from '../src/repositories/notificationTypeRepository';
import { NOTIFICATION_TYPE_NAMES } from '../src/types/general';

export class changeCancelProjectNotificationCopies1681206838965
implements MigrationInterface
{
private async updateNotificationType(
eventName: string,
data: {
htmlTemplate?: any;
content?: string;
},
) {
const notificationType = await getNotificationTypeByEventName(eventName);
if (!notificationType) {
return;
}
notificationType.htmlTemplate = data.htmlTemplate;
notificationType.content = data.content;
await notificationType.save();
}

public async up(queryRunner: QueryRunner): Promise<void> {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development'
) {
// Running these migrations in test and development environments would make the tests fail
// because the notification types are not created in the test database
// In future we should use raw SQL queries to update the notification types
return;
}
await this.updateNotificationType(
NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_OWNER,
{
htmlTemplate: [
{
type: 'p',
content: 'Your project ',
},
{
type: 'a',
content: '$projectTitle',
href: '$projectLink',
},
{
type: 'p',
content:
' has been canceled by an admin. More information can be found in our ',
},
{
type: 'a',
content: 'terms of service',
href: 'https://giveth.io/tos',
},
{
type: 'p',
content: '.',
},
],
content:
'Your project {project name} has been canceled by an admin. More information can be found in our {terms of service}.',
},
);

await this.updateNotificationType(
NOTIFICATION_TYPE_NAMES.PROJECT_CANCELLED_SUPPORTED,
{
htmlTemplate: [
{
type: 'a',
content: '$projectTitle',
href: '$projectLink',
},
{
type: 'p',
content: ' which you supported, has been canceled by an admin.',
},
],
content:
'{project name} which you supported, has been canceled by an admin.',
},
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
//
}
}
152 changes: 52 additions & 100 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"mocha": "9.2.2",
"pgtools": "^0.3.2",
"prettier": "2.5.1",
"ts-node": "10.7.0",
"ts-node-dev": "1.1.8",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typescript": "^4.5.2"
}
}