Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f7e4d91
feat: add dedupKey support for notifications
ilasw Sep 22, 2025
234b6d0
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Sep 23, 2025
11a5d71
feat: add support for warning reasons in SourcePostModeration flags
ilasw Sep 23, 2025
5bd9cce
feat: add support for multiple source posts creation with deduplicati…
ilasw Sep 23, 2025
512dadb
refactor: better post deduplication checks
ilasw Sep 23, 2025
c5f0e74
refactor: added isMultiplePosting check && removed unused context params
ilasw Sep 24, 2025
646ef2c
refactor: added transaction scope for post creation
ilasw Sep 24, 2025
83e08f1
Merge branch 'main' of https://github.com/dailydotdev/daily-api into …
ilasw Sep 24, 2025
6b237f2
feat: added dedupKey index and improved multiple source post creation…
ilasw Sep 25, 2025
4d80092
Merge branch 'main' of https://github.com/dailydotdev/daily-api into …
ilasw Sep 25, 2025
aa21828
test: clean up test data after each posts test run
ilasw Sep 25, 2025
c466221
test: updated moderation item tests to check falsy warningReason and …
ilasw Sep 25, 2025
65fcbe8
refactor: revert con to ctx reducing changes
ilasw Sep 25, 2025
a641e60
fix: wrong migration
ilasw Sep 25, 2025
ddb96ef
fix: missing optional image in schema
ilasw Sep 25, 2025
544afbf
fix: revert image field in post schema
ilasw Sep 25, 2025
23b9ede
feat: added externalLink and commentary fields to post schema and upd…
ilasw Sep 25, 2025
0c4bfac
Merge branch 'main' into mi-1043-multiple-squad-posting
AmarTrebinjac Sep 25, 2025
79c49c6
feat: added missing tests and force dedupKey on create shared post fu…
ilasw Sep 26, 2025
e76ce71
Merge remote-tracking branch 'origin/mi-1043-multiple-squad-posting' …
ilasw Sep 26, 2025
8774724
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Sep 26, 2025
4b74c9f
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Sep 26, 2025
11c58fd
fix: replaced safeParse with parse in posts schema and updated tests
ilasw Sep 26, 2025
3a8a82f
Merge remote-tracking branch 'origin/mi-1043-multiple-squad-posting' …
ilasw Sep 26, 2025
ace07c3
Merge branch 'main' of https://github.com/dailydotdev/daily-api into …
ilasw Sep 26, 2025
fc92c79
refactor: simplified query builders for post deduplication check
ilasw Sep 26, 2025
ae49fbc
Merge branch 'main' of https://github.com/dailydotdev/daily-api into …
ilasw Sep 29, 2025
76288eb
refactor: added transaction and EntityManager support in multiple sou…
ilasw Sep 29, 2025
a89e596
feat: added types for multiple sources post results and item types
ilasw Sep 29, 2025
76a3734
fix: linter
ilasw Sep 29, 2025
9d3a222
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Sep 29, 2025
9713a0a
fix: uniqueKey generation for notifications and updated tests
ilasw Sep 30, 2025
4175c0b
refactor: renamed isMultiplePosting to isMultiPost
ilasw Sep 30, 2025
08dc152
refactor: renamed createMultipleSourcesPost to createPostInMultipleSo…
ilasw Sep 30, 2025
26ab10c
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Sep 30, 2025
c01e373
feat: add multiple squads posting for polls (#3175)
ilasw Oct 1, 2025
8ff6199
Merge branch 'main' of https://github.com/dailydotdev/daily-api into …
ilasw Oct 2, 2025
b79064c
feat: added external link support for multiple squad posts
ilasw Oct 2, 2025
b68902f
refactor: simplified entityManager usage in post creation functions
ilasw Oct 2, 2025
f894315
refactor: replaced getOne with getExists
ilasw Oct 2, 2025
ae3f7b0
test: added test to ensure no duplicate notifications for posts with …
ilasw Oct 2, 2025
3f79f1d
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Oct 2, 2025
2e1e971
fix: removed unnecessary checks for post
ilasw Oct 2, 2025
dc74b90
Merge remote-tracking branch 'origin/mi-1043-multiple-squad-posting' …
ilasw Oct 2, 2025
4dadd0d
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Oct 3, 2025
9bfbd16
refactor: updated duplication checks
ilasw Oct 3, 2025
f8f4c9a
Merge remote-tracking branch 'origin/mi-1043-multiple-squad-posting' …
ilasw Oct 3, 2025
139b1bf
Merge branch 'main' into mi-1043-multiple-squad-posting
ilasw Oct 3, 2025
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
45 changes: 45 additions & 0 deletions __tests__/notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,51 @@ describe('storeNotificationBundle', () => {
expect(notifications.length).toEqual(3);
});

it('should not generate duplicate post added notifications for posts with same dedupKey', async () => {
await saveFixtures(con, User, usersFixture);

const dedupKey = 'p1';
const sharedCtx = {
userIds: [userId, '3', '4'],
source: sourcesFixture[0] as Reference<Source>,
user: usersFixture[1] as Reference<User>,
doneBy: usersFixture[1] as Reference<User>,
};
const ctx1 = {
...sharedCtx,
post: postsFixture[1] as Reference<Post>,
};
const ctx2 = {
...sharedCtx,
post: postsFixture[2] as Reference<Post>,
};

const notificationIds = await con.transaction(async (manager) => {
const results = await Promise.all([
storeNotificationBundleV2(
manager,
generateNotificationV2(NotificationType.SourcePostAdded, ctx1),
dedupKey,
),
storeNotificationBundleV2(
manager,
generateNotificationV2(NotificationType.SquadPostAdded, ctx2),
dedupKey,
),
]);
return results.flat();
});

const notifications = await con.getRepository(UserNotification).findBy({
notificationId: In(notificationIds.map((item) => item.id)),
});

expect(notifications.length).toEqual(3);
const uniqueKeys = notifications.map((item) => item.uniqueKey);
expect(new Set(uniqueKeys).size).toEqual(1);
expect(uniqueKeys[0]).toEqual(`post_added:dedup_${dedupKey}:post`);
});

it('should generate user_given_top_reader notification', async () => {
const topReader = {
id: 'cdaac113-0e8b-4189-9a6b-ceea7b21de0e',
Expand Down
Loading
Loading