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

Production release 2023-01-09 #28

Merged
merged 29 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c45bd0c
Change some title of notification setting
mohammadranjbarz Dec 19, 2022
1e95c39
Make Unstake/Stake notifications disabled
mohammadranjbarz Dec 19, 2022
9d37a50
Change notification setting copies
mohammadranjbarz Dec 19, 2022
e5c40e5
Create notificationType for givPower unlocked
mohammadranjbarz Dec 21, 2022
ac06b13
Changed givpower unlock method type
aminlatifi Dec 22, 2022
d77473d
Added transactionHash, networkId and poolName to givpower token unloc…
aminlatifi Dec 22, 2022
1b1e6b0
Updated test to pass
aminlatifi Dec 22, 2022
9504056
Merge pull request #21 from Giveth/fix/givpower_unlock_amount_type
aminlatifi Dec 22, 2022
6626850
Change category og givPower notifications to givEconomy
mohammadranjbarz Dec 25, 2022
bf4b840
Add projectBoosted notificationType
mohammadranjbarz Dec 26, 2022
9cab21a
Added GIVBACK IS READY event
aminlatifi Dec 27, 2022
b0f0512
Disabled givback is ready email
aminlatifi Dec 27, 2022
5fdb073
Implement sending bulk notifications
mohammadranjbarz Dec 27, 2022
0d1cb93
Made test compatible with new givback is paid event
aminlatifi Dec 27, 2022
833518d
Updated tests to be compatible with givback is paid / 2
aminlatifi Dec 27, 2022
7ef8ef0
Merge pull request #25 from Giveth/fix/change_givback_pay_template
mohammadranjbarz Dec 27, 2022
4aa5451
Updated givback is ready event template / 3
aminlatifi Dec 27, 2022
94e0e7a
Updated giback claim is ready tests to match new microservice type
aminlatifi Dec 27, 2022
d37fc71
Merge pull request #27 from Giveth/fix/change_givback_pay_template
aminlatifi Dec 27, 2022
d7a58cf
Fix sendBulkNotification test cases
mohammadranjbarz Dec 27, 2022
398f385
Add validation for uniqueness of trackIds in input data for sending b…
mohammadranjbarz Dec 28, 2022
fbd389e
Removed unused imports
aminlatifi Dec 28, 2022
1a04452
Merge pull request #26 from Giveth/f_24_send_bulk_notifications
aminlatifi Dec 29, 2022
f78076a
Change metadata validator for notifications
mohammadranjbarz Jan 2, 2023
e040e6b
Merge pull request #23 from Giveth/f_775_add_project-boosted_notifict…
mohammadranjbarz Jan 3, 2023
a90a054
Add Raw HTML Broadcast notificationType
mohammadranjbarz Jan 8, 2023
96f502d
Merge branch 'staging' of github.com:Giveth/notification-center into …
mohammadranjbarz Jan 8, 2023
b5ce8ac
Sort notificationSettings by notificationTypeId
mohammadranjbarz Jan 8, 2023
ed474b6
Fix getUserNotificationSettings sort query
mohammadranjbarz Jan 8, 2023
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
7 changes: 1 addition & 6 deletions migrations/1660539566228-createUserAddress.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
MigrationInterface,
QueryRunner,
Table,
TableForeignKey,
} from 'typeorm';
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createUserAddress1660539566228 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
Expand Down
8 changes: 1 addition & 7 deletions migrations/1660540253547-createNotificationType.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
MigrationInterface,
QueryRunner,
Table,
TableForeignKey,
TableIndex,
} from 'typeorm';
import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';

export class createNotificationType1660540253547 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion migrations/1660541108096-createNotificationSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class createNotificationSetting1660541108096
{
name: 'notificationTypeId',
type: 'int',
isNullable: true,
isNullable: false,
},
{
name: 'userAddressId',
Expand Down
125 changes: 90 additions & 35 deletions migrations/1660716115917-seedNotificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,29 @@ export const GivethNotificationTypes = {
content:
'The {project name} that you donated before is no longer visible.\n{reason}',
},
PROJECT_BOOSTED: {
name: 'Project boosted',
description: 'Project has been boosted',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.PROJECT_RELATED,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_BOOSTED,
emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT,
emailNotificationId: null,
pushNotifierService: null,
htmlTemplate: [
{
type: 'p',
content: 'Someone boosted your project ',
},
{
type: 'a',
content: '$projectTitle',
href: '$projectLink',
},
],
content: 'Someone boosted your project {projectName}!',
},
PROJECT_CANCELLED: {
name: 'Project cancelled',
description: 'Project has been cancelled',
Expand Down Expand Up @@ -873,6 +896,10 @@ export const GivethNotificationTypes = {
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.STAKING,
title: 'Stake',
isEmailEditable: false,
isWebEditable: false,
emailDefaultValue: false,
webDefaultValue: false,
htmlTemplate: [
{
type: 'p',
Expand All @@ -888,15 +915,15 @@ export const GivethNotificationTypes = {
},
{
type: 'a',
content: '$poolName',
content: '$contractName',
href: '/givfarm',
},
{
type: 'p',
content: ' was successful.',
},
],
content: 'Staking {amount} of {poolName} was successful.',
content: 'Staking {amount} of {contractName} was successful.',
},
UN_STAKE: {
name: 'UnStake',
Expand All @@ -909,6 +936,10 @@ export const GivethNotificationTypes = {
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.STAKING,
isEmailEditable: false,
isWebEditable: false,
emailDefaultValue: false,
webDefaultValue: false,
title: 'UnStake',
htmlTemplate: [
{
Expand All @@ -925,40 +956,40 @@ export const GivethNotificationTypes = {
},
{
type: 'a',
content: '$poolName',
content: '$contractName',
href: '/givfarm',
},
{
type: 'p',
content: ' was successful.',
},
],
content: 'Unstaking {amount} of {poolname} was successful.',
content: 'Unstaking {amount} of {contractName} was successful.',
},
GIV_BACKS_ARE_READY_TO_CLAIM: {
name: 'GIVbacks are ready to claim',
title: 'GIVbacks',
description: 'When GIVbacks are ready to be claimed after each round',
GIV_BACK_IS_READY_TO_CLAIM: {
name: 'GIVback is ready to claim',
title: 'GIVback',
description: 'When GIVback is ready to be claimed after each round',
showOnSettingPage: true,
microService: MICRO_SERVICES.givethio,
microService: MICRO_SERVICES.givEconomyNotificationMicroService,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: 'IconUnstake',
schemaValidator: SCHEMA_VALIDATORS_NAMES.GIV_FARM_READY_TO_CLAIM,
emailNotifierService: THIRD_PARTY_EMAIL_SERVICES.SEGMENT,
emailNotificationId: SegmentEvents.PROJECT_REJECTED,
icon: 'IconGIVBack',
schemaValidator: SCHEMA_VALIDATORS_NAMES.GIV_BACK_IS_READY_TO_CLAIM,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
htmlTemplate: [
{
type: 'p',
content: 'Your GIVbacks for round ',
content: 'Your GIVback ',
},
{
type: 'b',
content: '$round',
content: '$amount',
},
{
type: 'p',
content: ' are ready to claim! ',
content: ' GIV is ready to claim! ',
},
{ type: 'br' },
{
Expand All @@ -972,7 +1003,7 @@ export const GivethNotificationTypes = {
},
],
content:
'Your GIVbacks for round {round number} are ready to claim! \n{Click here} to take a shortcut.',
'Your GIVback {amount} GIV is ready to claim! \n[Click here] to take a shortcut.',
},
PROJECT_EDITED: {
name: 'Project edited',
Expand Down Expand Up @@ -1379,8 +1410,8 @@ export const GivethNotificationTypes = {

PROJECT_UPDATED_OWNER: {
name: 'Project updated - owner',
title: 'Project updates',
description: 'Your project update',
title: 'Your project update',
description: 'You Posted an update on your project',
showOnSettingPage: true,
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.PROJECT_RELATED,
Expand Down Expand Up @@ -1483,8 +1514,8 @@ export const GivethNotificationTypes = {
},
NEW_PROJECT_UPDATE_FOR_USERS_WHO_LIKED: {
name: 'Project updates',
title: 'Project updates',
description: 'Your liked project update',
title: 'Your liked project update',
description: 'When your liked project has an update',
showOnSettingPage: true,
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.PROJECT_RELATED,
Expand All @@ -1511,7 +1542,7 @@ export const GivethNotificationTypes = {
name: 'You boosted',
description: 'User boosted a project',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_BOOSTED,
emailNotifierService: null,
Expand Down Expand Up @@ -1548,7 +1579,7 @@ export const GivethNotificationTypes = {
name: 'You changed the allocation',
description: 'User changed boosted allocation',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_CHANGED_BOOSTED_ALLOCATION,
emailNotifierService: null,
Expand All @@ -1568,7 +1599,7 @@ export const GivethNotificationTypes = {
name: 'Your project has been boosted.',
description: 'Project has received a boosting',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.PROJECT_HAS_BEEN_BOOSTED,
emailNotifierService: null,
Expand Down Expand Up @@ -1601,7 +1632,7 @@ export const GivethNotificationTypes = {
name: 'You locked {amount} & recieved {amount} GIVpower',
description: 'User locked GIVpower',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_LOCKED_GIVPOWER,
emailNotifierService: null,
Expand Down Expand Up @@ -1634,10 +1665,10 @@ export const GivethNotificationTypes = {
content: 'You locked {amount} & recieved {amount} GIVpower',
},
YOU_UNLOCKED_GIVPOWER: {
name: '{amount} unlocked.',
name: 'givPower unlocked',
description: 'User unlocked GIVpower',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
microService: MICRO_SERVICES.givEconomyNotificationMicroService,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.USER_UNLOCKED_GIVPOWER,
emailNotifierService: null,
Expand All @@ -1661,7 +1692,7 @@ export const GivethNotificationTypes = {
name: '{amount} re-locked automatically',
description: 'User unlocked GIVpower',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_POWER,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator:
SCHEMA_VALIDATORS_NAMES.USER_GIVPOWER_RELOCKED_AUTOMATICALLY,
Expand Down Expand Up @@ -1712,7 +1743,7 @@ export const GivethNotificationTypes = {
title: 'Your boost status',
description:
'Shows when you boost a project, change the allocation of GIVpower.',
showOnSettingPage: true,
showOnSettingPage: false,
microService: MICRO_SERVICES.givethio,
schemaValidator: null,
emailNotifierService: null,
Expand Down Expand Up @@ -1756,8 +1787,9 @@ export const GivethNotificationTypes = {
},
PROJECT_STATUS_GROUP: {
name: 'Project status',
title: 'Project status',
description: 'Your project status',
title: 'Your project status',
description:
'When your own project has been listed, unlisted, cancelled, activated or deactivated',
showOnSettingPage: true,
isEmailEditable: true,
isWebEditable: false,
Expand Down Expand Up @@ -1809,7 +1841,7 @@ export const GivethNotificationTypes = {
microService: MICRO_SERVICES.givethio,
title: 'Stakes',
description: 'Shows when you stake or unstake on the GIVfarm',
showOnSettingPage: true,
showOnSettingPage: false,
schemaValidator: null,
emailNotifierService: null,
emailNotificationId: null,
Expand Down Expand Up @@ -1853,8 +1885,9 @@ export const GivethNotificationTypes = {
},
LIKED_BY_YOU_PROJECT_GROUP: {
name: 'Project status - Users Who Liked',
title: 'Project status',
description: 'Your liked project status',
title: 'Your liked project status',
description:
'When your liked Project has been listed, unlisted, cancelled, activated or deactivated',
showOnSettingPage: true,
microService: MICRO_SERVICES.givethio,
schemaValidator: null,
Expand All @@ -1873,6 +1906,28 @@ export const GivethNotificationTypes = {
icon: '',
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.LIKED_BY_YOU_PROJECT_GROUP,
},

RAW_HTML: {
name: 'Raw HTML Broadcast',
description: 'Raw HTML Broadcast',
microService: MICRO_SERVICES.givethio,
category: 'general',
icon: 'IconAdminNotif',
schemaValidator: SCHEMA_VALIDATORS_NAMES.RAW_HTML_BROADCAST,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
title: 'Raw HTML Broadcast',
htmlTemplate: [
{
type: 'html',
content: '$html',
},
],
Content: {
html: '',
},
},
};

export class seedNotificationType1660716115917 implements MigrationInterface {
Expand Down
6 changes: 5 additions & 1 deletion src/adapters/jwtAuthentication/mockJwtAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { JwtAuthenticationInterface } from './JwtAuthenticationInterface';
import { decode, JwtPayload } from 'jsonwebtoken';
import { errorMessages } from '../../utils/errorMessages';
import { logger } from '../../utils/logger';
import { StandardError } from '../../types/StandardError';

export class MockJwtAdapter implements JwtAuthenticationInterface {
verifyJwt(token: string): Promise<string> {
try {
const decodedJwt = decode(token) as JwtPayload;
if (!decodedJwt.publicAddress) {
throw new Error(errorMessages.UN_AUTHORIZED);
throw new StandardError({
message: errorMessages.UN_AUTHORIZED,
httpStatusCode: 401,
});
}
return decodedJwt.publicAddress.toLowerCase();
} catch (e: any) {
Expand Down
7 changes: 5 additions & 2 deletions src/controllers/v1/notificationSettingsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
import { UserAddress } from '../../entities/userAddress';
import { errorMessages } from '../../utils/errorMessages';
import {
sendNotificationValidator,
updateNotificationSettings,
updateOneNotificationSetting,
validateWithJoiSchema,
} from '../../validators/schemaValidators';
import { StandardError } from '../../types/StandardError';

interface SettingParams {
id: number;
Expand Down Expand Up @@ -86,7 +86,10 @@ export class NotificationSettingsController {
const notificationSetting = await findNotificationSettingById(id);

if (!notificationSetting) {
throw new Error(errorMessages.NOTIFICATION_SETTING_NOT_FOUND);
throw new StandardError({
message: errorMessages.NOTIFICATION_SETTING_NOT_FOUND,
httpStatusCode: 400,
});
}
const newSettingData = {
notificationSettingId: id,
Expand Down
Loading