feat: 为系统通知添加明确的操作结果摘要

为风险挑战确认和好友申请处理场景添加对应操作结果的中文摘要,替代原有的状态文本,让用户能更清晰地理解系统通知内容。
This commit is contained in:
Austin
2026-10-08 20:25:28 +08:00
parent 8228ceb89f
commit 1d8f9e3be4
2 changed files with 14 additions and 4 deletions
+6 -2
View File
@@ -6887,7 +6887,7 @@ func (a *adapter) TenantFriendRequestAccept(id t.TenantID, requestID string, act
eventType := "friend.request." + t.FriendRequestAccepted
applicantEventID := t.StableEventID("relation", row.RequestID+":"+t.FriendRequestAccepted, eventType, applicant.UserId())
if err = insertSystemNotificationTx(tx, id, applicant, t.StableEventID(applicantEventID, "notification"), eventType,
"好友申请已处理", t.FriendRequestAccepted, map[string]any{"type": "friend_request", "request_id": row.RequestID, "user_id": actor.UserId(), "topic": topic}); err != nil {
"好友申请已处理", "对方已同意你的好友申请", map[string]any{"type": "friend_request", "request_id": row.RequestID, "user_id": actor.UserId(), "topic": topic}); err != nil {
return nil, err
}
if err = tx.Commit(); err != nil {
@@ -6939,8 +6939,12 @@ func (a *adapter) TenantFriendRequestResolve(id t.TenantID, requestID string, ac
}
eventType := "friend.request." + status
eventID := t.StableEventID("relation", req.RequestID+":"+status, eventType, req.ApplicantID.UserId())
summary := "对方已婉拒你的好友申请"
if status == t.FriendRequestAccepted {
summary = "对方已同意你的好友申请"
}
if err = insertSystemNotificationTx(tx, id, req.ApplicantID, t.StableEventID(eventID, "notification"), eventType,
"好友申请已处理", status, map[string]any{"type": "friend_request", "request_id": req.RequestID, "user_id": actor.UserId()}); err != nil {
"好友申请已处理", summary, map[string]any{"type": "friend_request", "request_id": req.RequestID, "user_id": actor.UserId()}); err != nil {
return nil, err
}
if err = tx.Commit(); err != nil {
+8 -2
View File
@@ -1494,8 +1494,12 @@ func serveIMRiskChallengeConfirm(wrt http.ResponseWriter, req *http.Request) {
if imReliableHTTPEventsEnabled(req) {
eventType := "security.risk." + decision
eventID := stableIMEventID("risk", challengeID, decision, challenge.State)
summary := "你已取消本次操作"
if decision == "continue" {
summary = "你已确认继续执行该操作"
}
if err = createIMSystemNotification(principal.TenantID, principal.Uid,
stableIMEventID(eventID, "notification"), eventType, "安全操作确认", decision,
stableIMEventID(eventID, "notification"), eventType, "安全操作确认", summary,
types.KVMap{"risk_challenge_id": challengeID}); err != nil {
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
return
@@ -6410,11 +6414,13 @@ func serveIMFriendRequestAction(wrt http.ResponseWriter, req *http.Request) {
if imReliableHTTPEventsEnabled(req) {
eventType := "friend.request." + status
action := types.KVMap{}
summary := "对方已婉拒你的好友申请"
if status == types.FriendRequestAccepted {
action["topic"] = updated.ApplicantID.P2PName(updated.TargetID)
summary = "对方已同意你的好友申请"
}
if err = publishIMRelationEventWithAction(principal.TenantID, principal.Uid, updated.ApplicantID,
updated.RequestID+":"+status, eventType, "好友申请已处理", status, action); err != nil {
updated.RequestID+":"+status, eventType, "好友申请已处理", summary, action); err != nil {
writeIMError(wrt, req, http.StatusInternalServerError, 90000, imReasonInternal, "internal error", nil)
return
}