fix: sync persist conversation system notices
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user