Skip to content

Commit

Permalink
add in-app notifications for emails of superfluid
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Mar 28, 2024
1 parent 7700be6 commit bb67e9f
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 1 deletion.
161 changes: 161 additions & 0 deletions migrations/1711607882826-addSuperfluidNotifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { NOTIFICATION_CATEGORY_GROUPS } from '../src/entities/notificationSetting';
import { NOTIFICATION_CATEGORY } from '../src/types/general';
import { MICRO_SERVICES } from '../src/utils/utils';
import {
NotificationType,
SCHEMA_VALIDATORS_NAMES,
} from '../src/entities/notificationType';

export const superFluidNotificationTypes = [
{
name: 'One month left in stream balance',
description: 'Stream balance of underlying token will run out in 1 month',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.SUPERFLUID,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'One Month Left in Stream Balance',
htmlTemplate: [
{
type: 'p',
content: 'Your Stream Balance of ',
},
{
type: 'a',
content: '{underlyingTokenSymbol}',
href: '#', // Placeholder for dynamic token symbol link
},
{
type: 'p',
content: ' on ',
},
{
type: 'a',
content: '{network}',
href: '#', // Placeholder for dynamic network link
},
{
type: 'p',
content: ' will run out in 1 month, ',
},
{
type: 'a',
content: 'top-up here.',
href: 'Link to my recurring donations tab', // Actual link goes here
},
],
content:
'Your Stream Balance of {underlyingTokenSymbol} on {network} will run out in 1 month, top-up here.',
},
{
name: 'One week left in stream balance',
description: 'Stream balance of underlying token will run out in 1 week',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.SUPERFLUID,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'One Week Left in Stream Balance',
htmlTemplate: [
{
type: 'p',
content: 'Your Stream Balance of ',
},
{
type: 'a',
content: '{underlyingTokenSymbol}',
href: '#', // Placeholder for dynamic token symbol link
},
{
type: 'p',
content: ' on ',
},
{
type: 'a',
content: '{network}',
href: '#', // Placeholder for dynamic network link
},
{
type: 'p',
content: ' will run out in 1 week, ',
},
{
type: 'a',
content: 'top-up here.',
href: 'Link to my recurring donations tab', // Actual link goes here
},
],
content:
'Your Stream Balance of {underlyingTokenSymbol} on {network} will run out in 1 week, top-up here.',
},
{
name: 'Stream balance depleted',
description: 'Stream balance in token has run out of funds',
microService: MICRO_SERVICES.givethio,
category: NOTIFICATION_CATEGORY.GIV_ECONOMY,
icon: '',
schemaValidator: SCHEMA_VALIDATORS_NAMES.SUPERFLUID,
emailNotifierService: null,
emailNotificationId: null,
pushNotifierService: null,
categoryGroup: NOTIFICATION_CATEGORY_GROUPS.SUPERFLUID,
title: 'Stream Balance Depleted',
htmlTemplate: [
{
type: 'p',
content: 'Your Stream Balance in ',
},
{
type: 'a',
content: '{tokenSymbol}',
href: '#', // Placeholder for dynamic token symbol link
},
{
type: 'p',
content: ' on ',
},
{
type: 'a',
content: '{network}',
href: '#', // Placeholder for dynamic network link
},
{
type: 'p',
content:
' has run out of funds, subsequently some of your recurring donations have ended. ',
},
{
type: 'a',
content: 'Manage your Recurring Donations',
href: 'Link to manage recurring donations', // Actual link goes here
},
],
content:
'Your Stream Balance in {tokenSymbol} on {network} has run out of funds, subsequently some of your recurring donations have ended. Manage your Recurring Donations',
},
];

export class addSuperfluidNotifications1711607882826
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager.save(
NotificationType,
superFluidNotificationTypes,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DELETE FROM notification_type WHERE "categoryGroup" = 'superfluid';`,
);
}
}
1 change: 1 addition & 0 deletions src/entities/notificationSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { NotificationType } from './notificationType';
import { UserAddress } from './userAddress';

export const NOTIFICATION_CATEGORY_GROUPS = {
SUPERFLUID: 'superfluid',
GIVPOWER_ALLOCATIONS: 'givPowerAllocations',
PROJECT_BOOSTING_STATUS: 'projectBoostStatus',
SELF_BOOSTING_STATUS: 'yourBoostStatus',
Expand Down
1 change: 1 addition & 0 deletions src/entities/notificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { NotificationSetting } from './notificationSetting';

// Export Object with Schemas to N1 lookup
export const SCHEMA_VALIDATORS_NAMES = {
SUPERFLUID: 'superFluidTokenTrackerSchema',
ADMIN_MESSAGE: 'adminMessage',
RAW_HTML_BROADCAST: 'rawHtmlBroadcast',
DRAFTED_PROJECT_SAVED: 'draftedProjectSavedValidator',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validators/segmentAndMetadataValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const SEGMENT_METADATA_SCHEMA_VALIDATOR: {
};
} = {
userSuperTokensCritical: {
metadata: null,
metadata: superFluidTokenTrackerSchema,
segment: superFluidTokenTrackerSchema,
},
draftedProjectSavedValidator: {
Expand Down

0 comments on commit bb67e9f

Please sign in to comment.