package hub import "context" // Authorize is the §2.5 last-row check on its own: a participation // bound to this session, in this room, admitted. A member-kind // participation re-derives standing first (§15.12), exactly as Relay // does, through memberStandingGone; one whose standing is gone is ended // here with lost{standing} and answered ErrNotYours. A guest never // consults standing at all (ruling 14): memberStandingGone returns // immediately for a non-member kind, without a StandingFor call. // // A nil return is not "nothing happened": memberStandingGone still // records a kind that changed (setKindLocked), which — for an admitted // member — broadcasts a fresh roster to the room, the same side effect // Relay's own re-derivation has. What a nil return promises is only // that no *participation* ended and nothing was relayed; it is not a // pure read the way CanResume's probe is (that one never writes at // all). GET /m/{sqid}/ice is its caller. func (h *Hub) Authorize(ctx context.Context, sqid, session string, peer PeerID) error { gone, err := h.memberStandingGone(ctx, sqid, session, peer, true) if err != nil { return err } if gone { return ErrNotYours } h.mu.Lock() defer h.mu.Unlock() p, ok := h.findLocked(sqid, session, peer) if !ok { return ErrUnknownPeer } if !p.Admitted { return ErrNotAdmitted } return nil }