接入群消息实时提醒和重连补拉
This commit is contained in:
1 parent
5ace82b0d7
commit
b2e04e8174
10 files changed
+122
-33
No files matched your search
@@ -100,11 +100,15 @@ func (a *API) realtime(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
writeCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
event := "contacts_changed"
|
||||
event := map[string]string{"type": "contacts_changed"}
|
||||
if change.Channel == inboxChannel {
|
||||
event = "inbox_changed"
|
||||
event["type"] = "inbox_changed"
|
||||
if group, found := strings.CutPrefix(change.Payload, "group:"); found && uuidPattern.MatchString(group) {
|
||||
event["type"] = "group_changed"
|
||||
event["groupId"] = group
|
||||
}
|
||||
}
|
||||
err := wsjson.Write(writeCtx, conn, map[string]string{"type": event})
|
||||
err := wsjson.Write(writeCtx, conn, event)
|
||||
cancel()
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user