fix: sync persist conversation system notices

This commit is contained in:
richjohnrambo
2026-09-24 11:26:27 +08:00
parent 5ce04bad05
commit 5cea4d1e2e
2 changed files with 47 additions and 21 deletions
+16 -2
View File
@@ -75,16 +75,30 @@ func createIMSystemNotification(tenantID types.TenantID, uid types.Uid, eventID,
}
func publishIMRelationEvent(tenantID types.TenantID, actor, target types.Uid, stableID, eventType, title, summary string) error {
return publishIMRelationEventWithAction(tenantID, actor, target, stableID, eventType, title, summary, nil)
}
func publishIMRelationEventWithAction(tenantID types.TenantID, actor, target types.Uid, stableID, eventType, title, summary string, action types.KVMap) error {
if target.IsZero() {
return types.ErrMalformed
}
eventID := stableIMEventID("relation", stableID, eventType, target.UserId())
payload := map[string]any{"user_id": actor.UserId()}
notificationAction := types.KVMap{"user_id": actor.UserId()}
for key, value := range action {
key = strings.TrimSpace(key)
if key == "" || key == "user_id" {
continue
}
payload[key] = value
notificationAction[key] = value
}
if target != actor && title != "" {
if err := createIMSystemNotification(tenantID, target, stableIMEventID(eventID, "notification"), eventType,
title, summary, types.KVMap{"user_id": actor.UserId()}); err != nil {
title, summary, notificationAction); err != nil {
return err
}
}
return enqueueIMBusinessEvent(tenantID, eventID, "user", target.UserId(), actor, eventType,
map[string]any{"user_id": actor.UserId()})
payload)
}