This repository has been archived by the owner on Nov 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Group together notification types * Add "fromMember" to notifications and add type enums * Group notifications on type and link * Remove ping notifications on ping back * Disallow users to spam notifications or send to themselves * Fix missing optional chaining * Modify send notification logic * Gen graphql * Fix isues with names * Add logger to send notification method * Show avatars of relevant users on notifications * Add tests for getting notifications * Fix type of Link onClick to work with Markdown
- Loading branch information
Showing
26 changed files
with
1,578 additions
and
927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
backend/services/core/migrations/20230528113655_add_relevant_member_to_notifications.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Knex } from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('notifications', (table) => { | ||
table.uuid('from_member_id') | ||
.unsigned() | ||
.references('members.id') | ||
.onDelete('SET NULL') | ||
.comment('The member which took the action that initiated the notification. Null if not relevant.'); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('notifications', (table) => { | ||
table.dropColumn('from_member_id'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Knex } from 'knex'; | ||
import { DEFAULT_SUBSCRIPTION_SETTINGS } from '../../src/shared/notifications'; | ||
import { SQLNotification, SubscriptionSetting } from '../../src/types/notifications'; | ||
|
||
export async function insertSubscriptionSettings(knex: Knex, memberIds: string[]) { | ||
await knex<SubscriptionSetting>('subscription_settings').insert( | ||
memberIds.flatMap((memberId) => ( | ||
DEFAULT_SUBSCRIPTION_SETTINGS.map((setting) => ({ | ||
...setting, | ||
member_id: memberId, | ||
})))), | ||
); | ||
} | ||
|
||
export async function insertNotifications(knex: Knex, memberIds: string[]) { | ||
await knex<SQLNotification>('notifications').insert(memberIds.flatMap((memberId, index) => [{ | ||
link: '/news/article/testarticle', // not a valid link | ||
type: 'LIKE', | ||
title: 'Testartikel', | ||
message: 'Alfons Åberg har gillat din nyhet', | ||
member_id: memberId, | ||
from_member_id: memberIds[(index + 1) % memberIds.length], | ||
}, { | ||
link: '/news/article/testarticle', // not a valid link | ||
type: 'LIKE', | ||
title: 'Testartikel', | ||
message: 'Karlsson von Taket har gillat din nyhet', | ||
member_id: memberId, | ||
from_member_id: memberIds[(index + 2) % memberIds.length], | ||
}, { | ||
link: '/news/article/testarticle', // not a valid link | ||
type: 'LIKE', | ||
title: 'Testartikel', | ||
message: 'Findus Pettson har gillat din nyhet', | ||
member_id: memberId, | ||
from_member_id: memberIds[(index + 3) % memberIds.length], | ||
}, { | ||
link: '/news/article/testarticle', // not a valid link | ||
type: 'COMMENT', | ||
title: 'Mumin Trollet har kommenterat på Testartikel', | ||
message: 'Vilken spännande nyhet', | ||
member_id: memberId, | ||
from_member_id: memberIds[(index + 4) % memberIds.length], | ||
}, { | ||
link: '/news/article/testarticle', // not a valid link | ||
type: 'COMMENT', | ||
title: 'Tumme Lisa har kommenterat på Testartikel', | ||
message: 'Som jag väntat på när denna nyheten skulle komma, vad tycker du @Tumme Lisa?', | ||
member_id: memberId, | ||
from_member_id: memberIds[(index + 5) % memberIds.length], | ||
}])); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.