mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-22 02:55:52 -05:00
Add trust when joining a team via invite link
This commit is contained in:
@@ -285,13 +285,33 @@ export async function joinTeamViaInviteCode({
|
||||
throw new Response("Team is already full", { status: 400 });
|
||||
}
|
||||
|
||||
return db.tournamentTeamMember.create({
|
||||
data: {
|
||||
tournamentId,
|
||||
teamId: tournamentTeamToJoin.id,
|
||||
memberId: userId,
|
||||
},
|
||||
});
|
||||
const trustReceiverId = tournamentTeamToJoin.members.find(
|
||||
({ captain }) => captain
|
||||
)!.memberId;
|
||||
|
||||
return Promise.all([
|
||||
db.tournamentTeamMember.create({
|
||||
data: {
|
||||
tournamentId,
|
||||
teamId: tournamentTeamToJoin.id,
|
||||
memberId: userId,
|
||||
},
|
||||
}),
|
||||
// TODO: this could also be put to queue and scheduled for later
|
||||
db.trustRelationships.upsert({
|
||||
where: {
|
||||
trustGiverId_trustReceiverId: {
|
||||
trustGiverId: userId,
|
||||
trustReceiverId,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
trustGiverId: userId,
|
||||
trustReceiverId,
|
||||
},
|
||||
update: {},
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
export async function putPlayerToTeam({
|
||||
|
||||
Reference in New Issue
Block a user