From 5d4600a080ccb1f5800c7603004806075c70d2c4 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 7 Dec 2022 10:00:53 +0800 Subject: [PATCH] Separate the notification --- config/config.yaml | 13 +++++++++++++ internal/rpc/msg/friend_notification.go | 15 ++++++++++++--- internal/rpc/user/user.go | 4 +++- pkg/common/config/config.go | 6 ++++++ pkg/common/constant/constant.go | 1 + 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index f7758615b..2406108a3 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -665,6 +665,19 @@ notification: defaultTips: tips: "Remove a blocked user" + friendInfoUpdated: + conversation: + reliabilityLevel: 2 + unreadCount: false + offlinePush: + switch: true + title: "friend info updated" + desc: "friend info updated" + ext: "friend info updated" + defaultTips: + tips: "friend info updated" + + #####################user######################### userInfoUpdated: conversation: diff --git a/internal/rpc/msg/friend_notification.go b/internal/rpc/msg/friend_notification.go index 08f3880a5..1755c2d78 100644 --- a/internal/rpc/msg/friend_notification.go +++ b/internal/rpc/msg/friend_notification.go @@ -68,6 +68,8 @@ func friendNotification(commID *pbFriend.CommID, contentType int32, m proto.Mess tips.DefaultTips = cn.BlackDeleted.DefaultTips.Tips + toUserNickname case constant.UserInfoUpdatedNotification: tips.DefaultTips = cn.UserInfoUpdated.DefaultTips.Tips + case constant.FriendInfoUpdatedNotification: + tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname default: log.Error(commID.OperationID, "contentType failed ", contentType) return @@ -158,8 +160,15 @@ func BlackDeletedNotification(req *pbFriend.RemoveBlacklistReq) { friendNotification(req.CommID, constant.BlackDeletedNotification, &blackDeletedTips) } -func UserInfoUpdatedNotification(operationID, userID string, needNotifiedUserID string) { - selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: needNotifiedUserID} - commID := pbFriend.CommID{FromUserID: userID, ToUserID: needNotifiedUserID, OpUserID: userID, OperationID: operationID} +//send to myself +func UserInfoUpdatedNotification(operationID, opUserID string, changedUserID string) { + selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: changedUserID} + commID := pbFriend.CommID{FromUserID: opUserID, ToUserID: changedUserID, OpUserID: opUserID, OperationID: operationID} friendNotification(&commID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips) } + +func FriendInfoUpdatedNotification(operationID, changedUserID string, needNotifiedUserID string, opUserID string) { + selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: changedUserID} + commID := pbFriend.CommID{FromUserID: opUserID, ToUserID: needNotifiedUserID, OpUserID: opUserID, OperationID: operationID} + friendNotification(&commID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips) +} diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 3b11359ac..b6a55ca0f 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -444,12 +444,14 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI } for _, v := range rpcResp.FriendInfoList { log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, v.FriendUser.UserID) - chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, v.FriendUser.UserID) + // chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, v.FriendUser.UserID) + chat.FriendInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, v.FriendUser.UserID, req.OpUserID) } if err := rocksCache.DelUserInfoFromCache(user.UserID); err != nil { log.NewError(req.OperationID, "GetFriendList failed ", err.Error(), newReq) return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil } + //chat.UserInfoUpdatedNotification(req.OperationID, req.OpUserID, req.UserInfo.UserID) chat.UserInfoUpdatedNotification(req.OperationID, req.OpUserID, req.UserInfo.UserID) log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID) if req.UserInfo.FaceURL != "" { diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index f2906c2c0..2adf33b47 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -456,6 +456,12 @@ type config struct { OfflinePush POfflinePush `yaml:"offlinePush"` DefaultTips PDefaultTips `yaml:"defaultTips"` } `yaml:"blackDeleted"` + FriendInfoUpdated struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"friendInfoUpdated"` + ConversationOptUpdate struct { Conversation PConversation `yaml:"conversation"` OfflinePush POfflinePush `yaml:"offlinePush"` diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 54a3e2bc8..719541316 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -65,6 +65,7 @@ const ( FriendRemarkSetNotification = 1206 //set_friend_remark? BlackAddedNotification = 1207 //add_black BlackDeletedNotification = 1208 //remove_black + FriendInfoUpdatedNotification = 1209 ConversationOptChangeNotification = 1300 // change conversation opt