Skip to content

Conversation

@ilasw
Copy link
Contributor

@ilasw ilasw commented Sep 22, 2025

Jira ticket

MI-1043

@pulumi
Copy link

pulumi bot commented Sep 22, 2025

🍹 The Update (preview) for dailydotdev/api/prod (at 139b1bf) was successful.

Resource Changes

    Name                                                   Type                           Operation
~   vpc-native-update-highlighted-views-cron               kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-deployment              kubernetes:apps/v1:Deployment  update
~   vpc-native-update-views-cron                           kubernetes:batch/v1:CronJob    update
~   vpc-native-hourly-notification-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-user-companies-cron            kubernetes:batch/v1:CronJob    update
~   vpc-native-generate-search-invites-cron                kubernetes:batch/v1:CronJob    update
+   vpc-native-api-db-migration-ea9dd875                   kubernetes:batch/v1:Job        create
~   vpc-native-bg-deployment                               kubernetes:apps/v1:Deployment  update
~   vpc-native-sync-subscription-with-cio-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-daily-digest-cron                           kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-update-source-public-threshold-cron         kubernetes:batch/v1:CronJob    update
~   vpc-native-ws-deployment                               kubernetes:apps/v1:Deployment  update
~   vpc-native-validate-active-users-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-private-deployment                          kubernetes:apps/v1:Deployment  update
~   vpc-native-clean-zombie-users-cron                     kubernetes:batch/v1:CronJob    update
-   vpc-native-api-db-migration-34ee84f3                   kubernetes:batch/v1:Job        delete
~   vpc-native-calculate-top-readers-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-images-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-gifted-plus-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-update-source-tag-view-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tag-recommendations-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-clickhouse-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-update-current-streak-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tags-str-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-temporal-deployment                         kubernetes:apps/v1:Deployment  update
~   vpc-native-generic-referral-reminder-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-stale-user-transactions-cron          kubernetes:batch/v1:CronJob    update
~   vpc-native-check-analytics-report-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-update-trending-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-history-day-clickhouse-cron  kubernetes:batch/v1:CronJob    update
~   vpc-native-deployment                                  kubernetes:apps/v1:Deployment  update
-   vpc-native-api-clickhouse-migration-34ee84f3           kubernetes:batch/v1:Job        delete
+   vpc-native-api-clickhouse-migration-ea9dd875           kubernetes:batch/v1:Job        create

});
};

export const createFreeformPost = async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed, now createFreeformPost is a new function that also do some checks before insert

Comment on lines 1226 to 1229
export const createFreeformPost = async (
ctx: AuthContext,
args: CreatePostArgs,
) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the old createFreeformPost function plus the checks that the endpoint was doing before calling it

}));
},
editPost: async (
source,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was unused

type PostPermissions = SourcePermissions.Post | SourcePermissions.PostRequest;

export const canPostToSquad = (
ctx: Context,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not used by the function

@ilasw ilasw requested a review from Copilot September 25, 2025 14:23
@ilasw ilasw marked this pull request as ready for review September 25, 2025 14:23
@ilasw ilasw requested review from a team and capJavert as code owners September 25, 2025 14:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for multiple squad posting functionality and implements notification deduplication. The key changes enable users to create posts across multiple sources (squads) with a single operation while preventing duplicate notifications through a deduplication mechanism.

  • Adds a new createMultipleSourcePosts GraphQL mutation for cross-squad posting
  • Implements notification deduplication using dedupKey to prevent duplicate notifications
  • Adds warning reasons for moderation items to flag multiple squad posts and duplicated content

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/schema/posts.ts Adds new GraphQL mutation and resolver for multiple source posting with validation and permission checks
src/common/post.ts Implements core logic for creating posts across multiple sources with deduplication and warning systems
src/notifications/ Adds deduplication support to notifications system using dedupKey parameter
src/entity/SourcePostModeration.ts Adds warning reasons enum and deduplication flags to moderation system
src/migration/ Creates database index for deduplication key performance optimization
__tests__/posts.ts Comprehensive test coverage for multiple source posting functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

title: z.string().max(MAX_TITLE_LENGTH).optional(),
content: z.string().max(MAX_CONTENT_LENGTH).optional(),
image: z.custom<Promise<FileUpload>>(),
sourceIds: z.array(z.string()).min(1).max(MAX_MULTIPLE_POST_SOURCE_LIMIT),
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constant MAX_MULTIPLE_POST_SOURCE_LIMIT is defined but never used elsewhere. Consider adding a descriptive comment explaining why this specific limit exists and what happens when it's exceeded.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I half agree with the bot. I'm not sure if we need to define constants that aren't exported and only used one place in zod schemas ? 😅

@ilasw ilasw requested a review from capJavert September 30, 2025 14:05
Copy link
Contributor

@capJavert capJavert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels almost there, just please address final comments and I think we still miss tests for notification dedup part.

Comment on lines 497 to 499
return [uniqueKey, referenceId, referenceType, dedupKey]
.filter(Boolean)
.join(':');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still missing post notification tests for dedup logic?

@ilasw ilasw requested a review from capJavert October 3, 2025 07:45
return WarningReason.MultipleSquadPost;
}

return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

return WarningReason.DuplicatedInSameSquad;
}

const isDuplicatedAcrossSquads = await hasDuplicatedPostBy(con, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we call hasDuplicatedPostBy twice, once with sourceId once without? Would it not do the same thing if sourceId is not passed thus doing the query twice?

Copy link
Contributor

@rebelchris rebelchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non blocking, but good to check that one by Ante.
Logic wise will approve from my side.

return;
}

const isDuplicatedInSameSquad = await hasDuplicatedPostBy(con, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this could be 1 query 😅

Comment on lines +3333 to +3335
return await ctx.con.transaction(async (entityManager) => {
const output: Array<MultipleSourcesPostResult> = [];
for (const sourceId of sourceIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@capJavert the for loop works well with async right?
Or should be for await (?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works ok yes

@rebelchris
Copy link
Contributor

@claude please review this, but focus only on breaking changes.

@claude
Copy link

claude bot commented Oct 3, 2025

Claude finished @rebelchris's task —— View job


Breaking Changes Review

Reviewing PR for breaking changes as requested by @rebelchris.

Tasks:

  • Analyze GraphQL schema changes for API breaking changes
  • Review database migrations for schema breaking changes
  • Check core logic changes for behavioral breaking changes
  • Review entity changes for data model breaking changes
  • Provide focused breaking changes summary

NO BREAKING CHANGES IDENTIFIED

After thorough analysis of this PR, I found no breaking changes:

GraphQL API Changes:

  • ✅ Non-breaking: New mutation createPostInMultipleSources added (additive)
  • ✅ Non-breaking: New types MultiplePostItem and MultiplePostItemType enum added (additive)
  • ✅ Non-breaking: No existing mutations/queries modified or removed

Database Schema Changes:

  • ✅ Non-breaking: Only new index IDX_source_post_moderation_flags_dedupKey added (performance improvement)
  • ✅ Non-breaking: No table columns added/removed/modified
  • ✅ Non-breaking: No foreign key constraints changed

Entity & Data Model Changes:

  • ✅ Non-breaking: New enum WarningReason and flags added to SourcePostModerationFlags (optional fields)
  • ✅ Non-breaking: No existing fields removed or type changes

Core Logic Changes:

  • ✅ Non-breaking: New functions createFreeformPost and insertFreeformPost refactor existing logic without changing interfaces
  • ✅ Non-breaking: Notification deduplication is purely additive functionality
  • ✅ Non-breaking: No existing function signatures changed

Summary: This PR is safe to merge from a breaking changes perspective. All changes are additive features that enhance functionality without affecting existing APIs or data structures.

@ilasw ilasw merged commit 1839e7f into main Oct 3, 2025
9 checks passed
@ilasw ilasw deleted the mi-1043-multiple-squad-posting branch October 3, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants