实现 Windows 与 Web 加密文字群聊预览

This commit is contained in:
xhgit committed 2026-11-14 08:54:55 +08:00
1 parent 709e6aa6a6
commit ea6aec3323
19 files changed
+809 -31

No files matched your search

+2
View File
@@ -68,6 +68,8 @@ func New(accounts *account.Store, contactStore *contacts.Store, envelopeStore *d
mux.HandleFunc("POST /api/v1/groups/{id}/epochs", a.authorized(a.publishGroupEpoch))
mux.HandleFunc("GET /api/v1/groups/{id}/messages", a.authorized(a.groupInbox))
mux.HandleFunc("POST /api/v1/groups/{id}/messages", a.authorized(a.sendGroupMessage))
mux.HandleFunc("GET /api/v1/groups/{id}/devices", a.authorized(a.groupDevices))
mux.HandleFunc("POST /api/v1/groups/{id}/devices/{device}/claim", a.authorized(a.claimGroupPackage))
return a.boundary(mux)
}
@@ -10,6 +10,37 @@ import (
"xhchat/server/internal/groups"
)
func (a *API) groupDevices(w http.ResponseWriter, r *http.Request, _ string, actor account.Identity) {
id := r.PathValue("id")
if !uuidPattern.MatchString(id) {
groupError(w, groups.ErrUnavailable)
return
}
result, err := a.groups.Devices(r.Context(), id, actor.User.ID, actor.Device.ID)
if err != nil {
groupError(w, err)
return
}
respond(w, 200, result)
}
func (a *API) claimGroupPackage(w http.ResponseWriter, r *http.Request, _ string, actor account.Identity) {
id, target := r.PathValue("id"), strings.ToLower(r.PathValue("device"))
if !uuidPattern.MatchString(id) || !uuidPattern.MatchString(target) {
groupError(w, groups.ErrUnavailable)
return
}
if !a.limit(w, r, "group-claim:"+actor.Device.ID, 64) {
return
}
pack, err := a.groups.Claim(r.Context(), id, actor.User.ID, actor.Device.ID, target)
if err != nil {
groupError(w, err)
return
}
respond(w, 200, pack)
}
func (a *API) groupEpochs(w http.ResponseWriter, r *http.Request, _ string, actor account.Identity) {
id := r.PathValue("id")
if !uuidPattern.MatchString(id) {