Skip to content

five-on-it / apps/api/src/social / SocialHub

Class: SocialHub ​

Defined in: apps/api/src/social.ts:200

The social layer's state in the API's process (see the module documentation).

Constructors ​

Constructor ​

new SocialHub(friends, now?): SocialHub

Defined in: apps/api/src/social.ts:213

Parameters ​

friends ​

FriendBackend

now? ​

() => number

Returns ​

SocialHub

Properties ​

friends ​

readonly friends: FriendBackend

Defined in: apps/api/src/social.ts:202

Where the friends and the mutes live.

Methods ​

createParty() ​

createParty(account): PartyView

Defined in: apps/api/src/social.ts:330

Creates a party the account leads; refused while it is in one.

Parameters ​

account ​

Account

Returns ​

PartyView


decline() ​

decline(account, id): void

Defined in: apps/api/src/social.ts:368

Declines an invitation.

Parameters ​

account ​

Account

id ​

string

Returns ​

void


events() ​

events(id, after, waitMs?): Promise<{ events: SocialEvent[]; next: number; }>

Defined in: apps/api/src/social.ts:276

The account's events after after (all those kept for 0), and the number to ask after next time; with none yet, waits up to waitMs for one.

Parameters ​

id ​

string

after ​

number

waitMs? ​

number = 0

Returns ​

Promise<{ events: SocialEvent[]; next: number; }>


followers() ​

followers(id): string[]

Defined in: apps/api/src/social.ts:391

The other members of an account's party, when it leads one.

Parameters ​

id ​

string

Returns ​

string[]


invite() ​

invite(account, other): PartyView

Defined in: apps/api/src/social.ts:341

The leader (or any member) invites a friend; the friend hears of it.

Parameters ​

account ​

Account

other ​

string

Returns ​

PartyView


invitesOf() ​

invitesOf(id): object[]

Defined in: apps/api/src/social.ts:323

The parties that invited an account.

Parameters ​

id ​

string

Returns ​

object[]


isGuest() ​

isGuest(id): boolean

Defined in: apps/api/src/social.ts:230

Whether an account was last seen as a guest's (a dev guest's id says so too).

Parameters ​

id ​

string

Returns ​

boolean


joinParty() ​

joinParty(account, id): PartyView

Defined in: apps/api/src/social.ts:354

An invited account joins the party (leaving the one it was in).

Parameters ​

account ​

Account

id ​

string

Returns ​

PartyView


leaveParty() ​

leaveParty(id): void

Defined in: apps/api/src/social.ts:374

An account leaves its party: the next member leads, the last one out ends it.

Parameters ​

id ​

string

Returns ​

void


party() ​

party(id): PartyView | undefined

Defined in: apps/api/src/social.ts:305

The party an account is in, as its members see it; undefined for none.

Parameters ​

id ​

string

Returns ​

PartyView | undefined


partyIdOf() ​

partyIdOf(id): string | undefined

Defined in: apps/api/src/social.ts:318

The id of the party an account is in.

Parameters ​

id ​

string

Returns ​

string | undefined


person() ​

person(id): Person

Defined in: apps/api/src/social.ts:235

An account as others see it.

Parameters ​

id ​

string

Returns ​

Person


presenceOf() ​

presenceOf(id): object

Defined in: apps/api/src/social.ts:246

Whether an account is online, and the room it is in.

Parameters ​

id ​

string

Returns ​

object

online ​

online: boolean

room ​

room: string | null


push() ​

push(id, event): void

Defined in: apps/api/src/social.ts:264

Adds an event to an account's feed and wakes the pages waiting on it.

Parameters ​

id ​

string

event ​

Omit<{ at: string; channel: "party" | "direct"; from: Person; kind: "message"; n: number; text: string; to?: Person; }, "n"> | Omit<{ kind: "friends"; n: number; }, "n"> | Omit<{ kind: "party"; n: number; }, "n"> | Omit<{ from: Person; kind: "invite"; n: number; party: string; }, "n"> | Omit<{ by: Person; joinUrl: string; kind: "room"; n: number; room: string; }, "n"> | Omit<{ from?: Person; kind: "lobby"; lobby: string; n: number; state: "gathering" | "countdown" | "closed" | "running" | "ready" | "results"; text?: string; title?: string; view?: { canStart: boolean; countdown: { seconds: number; waiting: boolean; } | null; game: { by: string; curated: boolean; id: string; level: string; rating: { average: number; count: number; }; title: string; }; host: string | null; id: string; join?: { joinUrl: string; room: string; run: string; }; max: number; mission: { blurb: string | null; id: string; rules: { each: boolean; friendlyFire: boolean; joinInProgress: "never" | "untilCheckpoint" | "always"; lives: { count: number; per: "player" | "team"; } | null; mode: "solo" | "coop" | "versus"; onDeath: "checkpoint" | "spectate" | "teamSpawn"; players: { max: number; min: number; }; respect: number | null; retries: number; teams: object[]; timeLimit: number | null; }; title: string; }; notice: { code: "busy" | "gaveUp" | "refused" | "inRun"; text: string; } | null; players: number; playlist?: "any" | "coop" | "versus" | "races" | null; results: { forfeit: boolean; mission: string; outcome: "complete" | "failed" | "abandoned" | "won" | "draw" | "lost"; run: string | null; seats: object[]; seconds: number | null; title: string; winner: string | null; winnerName: string | null; } | null; run: string | null; state: "gathering" | "countdown" | "running" | "ready" | "results"; teams: object[]; visibility: "private" | "public"; vote: { endsIn: number; mine: "level" | "game" | "same" | "replay" | null; offers: object[]; } | null; you: string | null; }; why: "kicked" | "changed" | "removed" | "closed" | "results" | "joined" | "invite"; }, "n"> | Omit<{ joinUrl: string; kind: "run"; lobby: string; n: number; room: string; run: string; }, "n"> | Omit<{ job: string; kind: "creation"; n: number; revision?: number; state: "done" | "failed" | "waiting" | "cancelled"; title: string; }, "n"> | Omit<{ from: Person; kind: "endorsed"; n: number; respect: number; run: string; }, "n">

Returns ​

void


sayTo() ​

sayTo(account, token, to, text): Promise<void>

Defined in: apps/api/src/social.ts:431

A direct message to a friend: both read it.

Parameters ​

account ​

Account

token ​

string

to ​

string

text ​

string

Returns ​

Promise<void>


sayToParty() ​

sayToParty(account, text): Promise<void>

Defined in: apps/api/src/social.ts:420

A line on the party's channel: every member reads it, the sender too.

Parameters ​

account ​

Account

text ​

string

Returns ​

Promise<void>


seen() ​

seen(account): void

Defined in: apps/api/src/social.ts:219

An account was seen: its name is known from now on.

Parameters ​

account ​

Account

Returns ​

void


setPresence() ​

setPresence(account, room): void

Defined in: apps/api/src/social.ts:240

Where an account's page says it is (null: no room); it is online from now on.

Parameters ​

account ​

Account

room ​

string | null

Returns ​

void