mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 15:17:43 -05:00
Fix can't add friend to pick-up scrim with no friend code
This commit is contained in:
@@ -161,7 +161,9 @@ async function validatePickup(userIds: number[], authorId: number) {
|
||||
async function validatePickupFriends(userIds: number[], authorId: number) {
|
||||
const unconsentingUsers: string[] = [];
|
||||
|
||||
const friendsData = await SQGroupRepository.friendsAndTeammates(authorId);
|
||||
const friendsData = await SQGroupRepository.friendsAndTeammates(authorId, {
|
||||
requireFriendCode: false,
|
||||
});
|
||||
|
||||
for (const userId of userIds) {
|
||||
const user = await UserRepository.findLeanById(userId);
|
||||
|
||||
@@ -417,7 +417,10 @@ export function rechallenge({
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function friendsAndTeammates(userId: number) {
|
||||
export async function friendsAndTeammates(
|
||||
userId: number,
|
||||
{ requireFriendCode = true }: { requireFriendCode?: boolean } = {},
|
||||
) {
|
||||
const teams = await db
|
||||
.selectFrom("TeamMemberWithSecondary")
|
||||
.innerJoin("Team", "Team.id", "TeamMemberWithSecondary.teamId")
|
||||
@@ -428,7 +431,9 @@ export async function friendsAndTeammates(userId: number) {
|
||||
const rows = await db
|
||||
.selectFrom("TeamMemberWithSecondary")
|
||||
.innerJoin("User", "User.id", "TeamMemberWithSecondary.userId")
|
||||
.innerJoin("UserFriendCode", "UserFriendCode.userId", "User.id")
|
||||
.$if(requireFriendCode, (qb) =>
|
||||
qb.innerJoin("UserFriendCode", "UserFriendCode.userId", "User.id"),
|
||||
)
|
||||
.select([
|
||||
...COMMON_USER_FIELDS,
|
||||
"User.inGameName",
|
||||
@@ -456,7 +461,9 @@ export async function friendsAndTeammates(userId: number) {
|
||||
]),
|
||||
),
|
||||
)
|
||||
.innerJoin("UserFriendCode", "UserFriendCode.userId", "User.id")
|
||||
.$if(requireFriendCode, (qb) =>
|
||||
qb.innerJoin("UserFriendCode", "UserFriendCode.userId", "User.id"),
|
||||
)
|
||||
.select([
|
||||
...COMMON_USER_FIELDS,
|
||||
"User.inGameName",
|
||||
|
||||
Reference in New Issue
Block a user