Document mergeInvitation
This commit is contained in:
@@ -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<typeof parseInvitation>, invitation2: Z.infer<typeof parseInvitation> | undefined): Z.infer<typeof parseInvitation> {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user