为双端群聊增加端到端加密附件

This commit is contained in:
xhgit committed 2026-11-14 09:05:40 +08:00
1 parent 5988ad6ed6
commit a95a007768
21 files changed
+405 -84

No files matched your search

+8 -5
View File
@@ -108,18 +108,21 @@ func (a *API) sendGroupMessage(w http.ResponseWriter, r *http.Request, _ string,
return
}
var input struct {
ID string `json:"id"`
Epoch string `json:"epoch"`
Wire []byte `json:"wire"`
ID string `json:"id"`
Epoch string `json:"epoch"`
Wire []byte `json:"wire"`
AttachmentID *string `json:"attachmentId,omitempty"`
}
if !parseLimit(w, r, &input, 96<<10) {
return
}
if !uuidPattern.MatchString(input.ID) || !uuidPattern.MatchString(input.Epoch) || !mlsFrame(input.Wire) || input.Wire[3] != 2 {
if !uuidPattern.MatchString(input.ID) || !uuidPattern.MatchString(input.Epoch) || !mlsFrame(input.Wire) || input.Wire[3] != 2 ||
input.AttachmentID != nil && !uuidPattern.MatchString(*input.AttachmentID) {
problem(w, 400, "invalid_group_message", "群消息密文无效")
return
}
sequence, err := a.groups.Send(r.Context(), id, actor.User.ID, actor.Device.ID, groups.Message{ID: input.ID, Epoch: input.Epoch, Wire: input.Wire})
message := groups.Message{ID: input.ID, Epoch: input.Epoch, Wire: input.Wire, AttachmentID: input.AttachmentID}
sequence, err := a.groups.Send(r.Context(), id, actor.User.ID, actor.Device.ID, message)
if err != nil {
groupError(w, err)
return