fix: persist group join system notices

This commit is contained in:
richjohnrambo
2026-09-15 19:20:07 +08:00
parent 563ae9ee5e
commit b7c2536527
2 changed files with 100 additions and 0 deletions
+32
View File
@@ -5619,6 +5619,11 @@ func serveIMGroupInvitations(wrt http.ResponseWriter, req *http.Request, topic s
}
if joined {
item["status"] = types.GroupInvitationStatusJoined
if imReliableHTTPEventsEnabled(req) {
publishIMGroupMemberJoinedSystemNotice(principal.TenantID, topic, principal.Uid, uid,
"有成员通过邀请加入了群聊。",
map[string]any{"source": "direct_invitation"})
}
} else {
item["status"] = "already_member"
}
@@ -5863,6 +5868,11 @@ func serveIMGroupJoinRequests(wrt http.ResponseWriter, req *http.Request, topic
}
publishIMGroupRealtimeEvent(principal.TenantID, topic, principal.Uid, "group.member.joined",
map[string]any{"user_id": principal.Uid.UserId(), "joined": joined, "source": "open_group"})
if joined && imReliableHTTPEventsEnabled(req) {
publishIMGroupMemberJoinedSystemNotice(principal.TenantID, topic, principal.Uid, principal.Uid,
"有成员加入了群聊。",
map[string]any{"source": "open_group"})
}
writeIMSuccess(wrt, req, map[string]any{"topic": topic, "status": "joined", "joined": joined, "source": "open_group"})
return
}
@@ -11652,6 +11662,28 @@ func publishIMGroupInvitationNotification(tenantID types.TenantID, inv *types.Gr
}
}
func publishIMGroupMemberJoinedSystemNotice(tenantID types.TenantID, topic string, inviter, target types.Uid, text string, extra map[string]any) {
if target.IsZero() {
return
}
actors := make([]imSystemMessageActor, 0, 2)
if !inviter.IsZero() && inviter != target {
actors = append(actors, imSystemMessageActor{
UserID: inviter.UserId(),
Click: map[string]any{"type": "user_profile", "target_id": inviter.UserId()},
})
}
actors = append(actors, imSystemMessageActor{
UserID: target.UserId(),
Click: map[string]any{"type": "user_profile", "target_id": target.UserId()},
})
publishIMConversationSystemNotice(tenantID, topic,
"system_action", "group_member_joined", text,
actors,
[]imSystemMessageAction{{Type: "group_profile", Label: "查看群聊", TargetID: topic}},
extra)
}
func deliverIMConversationSystemMessageToP2PSessions(tenantID types.TenantID, msg *types.Message, out *ServerComMessage) {
if globals.sessionStore == nil || msg == nil || out == nil || out.Data == nil {
return