package api import ( "net/http" userclasses "git.golem15.com/golem15/sm-user-plugin/classes" ) // chatBootstrapJSON is the answer of /chat. A user outside the chat group // gets only member: false. type chatBootstrapJSON struct { Member bool `json:"member"` } // Chat answers GET /chat, the chat bootstrap: whether the caller is in the // chat group. func (h *Handlers) Chat(w http.ResponseWriter, r *http.Request) { userID, ok := h.caller(w, r) if !ok { return } db, ok := h.db(w, r) if !ok { return } member := false if h.ChatGroup != "" { var err error member, err = userclasses.HasGroupCode(r.Context(), db, userID, h.ChatGroup) if err != nil { writeOpaque500(w) return } } writeData(w, chatBootstrapJSON{Member: member}) }