Add serverside check that group is in the looking pool

This commit is contained in:
Kalle
2026-08-23 16:37:09 +03:00
parent 1d8551898e
commit 635e8ab0ec
3 changed files with 15 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ import { parseFormData } from "~/form/parse.server";
import { errorToastIfFalsy } from "~/utils/remix.server";
import { assertUnreachable } from "~/utils/types";
import { SENDOUQ_PAGE, SENDOUQ_READY_PAGE } from "~/utils/urls";
import { canSuggest, groupAfterMorph } from "../core/groups";
import { canSuggest, groupAfterMorph, isInLookingPool } from "../core/groups";
import * as ReadyCheck from "../core/ready-check.server";
import { refreshSendouQInstance, SendouQ } from "../core/SendouQ.server";
import { lookingSchema } from "../q-action-schemas";
@@ -38,6 +38,10 @@ export const action: ActionFunction = async ({ request }) => {
const currentGroup = SendouQ.findOwnGroup(user.id);
if (!currentGroup) return null;
if (data._action !== "LEAVE_GROUP" && !isInLookingPool(currentGroup)) {
return null;
}
const broadcastLookingUpdate = () =>
ChatSystemMessage.send({
room: SENDOUQ_LOOKING_ROOM,

View File

@@ -25,6 +25,7 @@ import {
import { FULL_GROUP_SIZE } from "../q-constants";
import type { TierRange } from "../q-types";
import { getTierIndex } from "../q-utils.server";
import { isInLookingPool } from "./groups";
import { tierDifferenceToRangeOrExact } from "./groups.server";
import * as ReadyCheck from "./ready-check.server";
@@ -567,8 +568,7 @@ class SendouQClass {
ownGroupId?: number;
currentMemberCountOptions?: number[];
}) {
if (group.status !== "ACTIVE") return false;
if (group.matchId) return false;
if (!isInLookingPool(group)) return false;
if (group.id === ownGroupId) return false;
if (
currentMemberCountOptions &&

View File

@@ -1,3 +1,4 @@
import type { Tables } from "~/db/tables";
import { databaseTimestampToDate } from "~/utils/dates";
import type { GroupExpiryStatus } from "../q-types";
import type { SQGroup } from "./SendouQ.server";
@@ -32,6 +33,13 @@ export function groupAfterMorph({
return ourGroup;
}
export function isInLookingPool(group: {
status: Tables["Group"]["status"];
matchId: number | null;
}) {
return group.status === "ACTIVE" && !group.matchId;
}
/**
* Whether the group's members can suggest other groups to each other. A suggestion
* is a pointer for teammates, so a solo group has no one to point at anything.