oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1package calls
2
3import (
4 "context"
5
6 "amadan.net/oficina/calls/internal/calls/hub"
7)
8
9// hubStanding is hub.Config.StandingFor: the app's standing (spec §2.3)
10// in the two facts the hub keeps — the kind a participation holds, and
11// whether the person still has entry authority for the room at all.
12//
13// It is never called under the hub's lock: the hub drops the lock
14// before every standing read, because this reads the database.
15//
16// A meeting that has ended, or that no longer exists, answers ok=false
17// with no error, which is what a lapsed grant answers too: the tick
18// then applies §2.4's transitions rather than treating it as a failure
19// to retry on the next tick.
20//
21// That ended-meeting arm is belt and braces, and deliberately so
22// (review W-5): every path that reaches a room already refuses an ended
23// meeting earlier — roomAccess on the pages, and the stream handler
24// which reads ended_at before it attaches, because End no longer writes
25// a headstone for a room that was never opened. Removing it here would
26// break nothing today and would make this function's answer depend on
27// its callers all continuing to check first.
28func (a *app) hubStanding(ctx context.Context, sqid string, personID int64) (hub.Kind, bool, error) {
29 m, ok, err := a.store.meetingBySqid(ctx, sqid)
30 if err != nil {
31 return hub.KindGuest, false, err
32 }
33 if !ok || m.EndedAt != nil {
34 return hub.KindGuest, false, nil
35 }
36 p, ok, err := a.store.personByID(ctx, personID)
37 if err != nil {
38 return hub.KindGuest, false, err
39 }
40 if !ok {
41 return hub.KindGuest, false, nil
42 }
43 st, err := a.standingFor(ctx, p, m)
44 if err != nil {
45 return hub.KindGuest, false, err
46 }
47 switch st {
48 case StandingMember:
49 return hub.KindMember, true, nil
50 case StandingGuest:
51 return hub.KindGuest, true, nil
52 }
53 return hub.KindGuest, false, nil
54}
55