增加按设备统计的群消息未读角标
This commit is contained in:
1 parent
f54077ce46
commit
187923ca3c
16 files changed
+189
-23
No files matched your search
@@ -65,6 +65,7 @@ func New(accounts *account.Store, contactStore *contacts.Store, envelopeStore *d
|
||||
mux.HandleFunc("GET /api/v1/groups/{id}", a.authorized(a.groupDetail))
|
||||
mux.HandleFunc("POST /api/v1/groups/{id}", a.authorized(a.changeGroup))
|
||||
mux.HandleFunc("POST /api/v1/groups/{id}/preferences", a.authorized(a.setGroupPreferences))
|
||||
mux.HandleFunc("POST /api/v1/groups/{id}/seen", a.authorized(a.markGroupSeen))
|
||||
mux.HandleFunc("GET /api/v1/groups/{id}/epochs", a.authorized(a.groupEpochs))
|
||||
mux.HandleFunc("POST /api/v1/groups/{id}/epochs", a.authorized(a.publishGroupEpoch))
|
||||
mux.HandleFunc("GET /api/v1/groups/{id}/messages", a.authorized(a.groupInbox))
|
||||
|
||||
@@ -183,3 +183,30 @@ func (a *API) groupInbox(w http.ResponseWriter, r *http.Request, _ string, actor
|
||||
}
|
||||
respond(w, 200, items)
|
||||
}
|
||||
|
||||
func (a *API) markGroupSeen(w http.ResponseWriter, r *http.Request, _ string, actor account.Identity) {
|
||||
group := r.PathValue("id")
|
||||
if !uuidPattern.MatchString(group) {
|
||||
groupError(w, groups.ErrUnavailable)
|
||||
return
|
||||
}
|
||||
var input struct {
|
||||
Sequence string `json:"sequence"`
|
||||
}
|
||||
if !parse(w, r, &input) {
|
||||
return
|
||||
}
|
||||
sequence, err := strconv.ParseInt(input.Sequence, 10, 64)
|
||||
if err != nil || sequence <= 0 || strconv.FormatInt(sequence, 10) != input.Sequence {
|
||||
problem(w, 400, "invalid_cursor", "无效的已查看游标")
|
||||
return
|
||||
}
|
||||
if !a.limit(w, r, "group-seen:"+actor.Device.ID, 240) {
|
||||
return
|
||||
}
|
||||
if err = a.groups.MarkSeen(r.Context(), group, actor.User.ID, actor.Device.ID, sequence); err != nil {
|
||||
groupError(w, err)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(204)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func (a *API) createGroup(w http.ResponseWriter, r *http.Request, _ string, id a
|
||||
}
|
||||
|
||||
func (a *API) listGroups(w http.ResponseWriter, r *http.Request, _ string, id account.Identity) {
|
||||
result, err := a.groups.List(r.Context(), id.User.ID)
|
||||
result, err := a.groups.List(r.Context(), id.User.ID, id.Device.ID)
|
||||
if err != nil {
|
||||
groupError(w, err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user