From 7e887b4c33ee463b9c8e4b1f367207ce22d57508 Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Wed, 20 May 2026 16:48:27 +0000 Subject: [PATCH] Document mergeInvitation --- src/routes/invitations.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/routes/invitations.ts b/src/routes/invitations.ts index ab12fa5..5fbabdc 100644 --- a/src/routes/invitations.ts +++ b/src/routes/invitations.ts @@ -86,16 +86,30 @@ export class InvitationsRoute { return reply.status(200).send(invitation); } + /** + * Merge two invitations by commit identifiers. + * This wont work in an actual commit merging situation since the invitations will be encrypted. + * + * @param invitation1 - The first invitation. + * @param invitation2 - The second invitation. + * @returns The merged invitation. + */ static mergeInvitations(invitation1: Z.infer, invitation2: Z.infer | undefined): Z.infer { + // Initialize the result with the first invitation. const result = invitation1; + // Loop over the commits in the second invitation. for(const commit of invitation2?.commits ?? []) { + // If the commit already exists in the result, skip it. if(result.commits.some(c => c.commitIdentifier === commit.commitIdentifier)) { continue; } + + // Add the commit to the result. result.commits.push(commit); } + // Return the merged invitation. return result; }