mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 07:01:27 -07:00
[match] fix 2025 game invites
This commit is contained in:
@@ -64,6 +64,27 @@ export enum MessageType {
|
||||
VirtualRoomNotification = 100008,
|
||||
}
|
||||
|
||||
/**
|
||||
* What a v2 game invite (`MessageType.GameInviteV2`) is ASKING FOR — the `InviteMode` in
|
||||
* its `Data` envelope. It's the intent behind the invite, not the room being invited into:
|
||||
* the same instance is named whether you're pulling a party along or asking one player to
|
||||
* come play.
|
||||
*
|
||||
* The values are sparse and grouped: 0–4 are the party-management modes, 20+ the invite
|
||||
* ones. A plain "join me" is {@link PlayTogether}; {@link InviteParty} is the other
|
||||
* reading of it, and the two have not been told apart on the wire yet.
|
||||
*/
|
||||
export enum InviteMode {
|
||||
None = 0,
|
||||
LeaveParty = 1,
|
||||
InviteParty = 2,
|
||||
PartyAutoFollow = 3,
|
||||
EveryoneAutoFollow = 4,
|
||||
InviteOnlineFriends = 20,
|
||||
FullInstanceReinvite = 21,
|
||||
PlayTogether = 22,
|
||||
}
|
||||
|
||||
/**
|
||||
* A room's (or image's) visibility, matching the client's `RoomAccessibility`. The
|
||||
* client declares the enum without explicit values, so these are its ordinals — and
|
||||
@@ -140,6 +161,7 @@ export enum MatchmakingErrorCode {
|
||||
MetaJuniorAccountRestriction = 83,
|
||||
NotExclusivelyLoggedIn = 84,
|
||||
AccountDoesNotExist = 85,
|
||||
RoomInstanceBlockedByMatchmakingPolicy = 86,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
export { RoomInstanceType, Accessibility, Role, MessageType, MatchmakingErrorCode } from './enums'
|
||||
export {
|
||||
RoomInstanceType,
|
||||
Accessibility,
|
||||
Role,
|
||||
MessageType,
|
||||
InviteMode,
|
||||
MatchmakingErrorCode,
|
||||
} from './enums'
|
||||
export * from './accounts-db'
|
||||
export * from './clubs-db'
|
||||
export * from './images-db'
|
||||
|
||||
@@ -60,6 +60,31 @@ const SELECT_COLUMNS = `room_invite_id, from_player_id, to_player_id, room_id`
|
||||
|
||||
const nowSeconds = () => Math.floor(Date.now() / 1000)
|
||||
|
||||
/**
|
||||
* One invite by its id, or null when there is no such row.
|
||||
*
|
||||
* Null covers BOTH "never existed" and "already expired" — the sweep deletes expired rows
|
||||
* rather than flagging them, and {@link ROOM_INVITE_SCHEMA_DDL} keeps ids from being
|
||||
* reused, so a lookup that misses is an invite that is no longer good either way.
|
||||
*/
|
||||
export async function getRoomInvite(
|
||||
db: D1Database,
|
||||
roomInviteId: number
|
||||
): Promise<RoomInvite | null> {
|
||||
const row = await db
|
||||
.prepare(`SELECT ${SELECT_COLUMNS} FROM room_invite WHERE room_invite_id = ?1`)
|
||||
.bind(roomInviteId)
|
||||
.first<RoomInviteRow>()
|
||||
|
||||
if (!row) return null
|
||||
return {
|
||||
RoomInviteId: row.room_invite_id,
|
||||
FromPlayerId: row.from_player_id,
|
||||
ToPlayerId: row.to_player_id,
|
||||
RoomId: row.room_id,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Record an invite from `fromPlayerId` to `toPlayerId` for a room, returning it as the
|
||||
* client reads it back. `roomId` is null when the caller's room instance didn't resolve.
|
||||
|
||||
Reference in New Issue
Block a user