From b84dbbc3b8c18d33b16aed4c60ef1833397cec2a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 14 Dec 2021 15:11:35 +0800 Subject: [PATCH] notification --- cmd/Open-IM-SDK-Core | 2 +- internal/rpc/chat/send_msg.go | 6 ++--- internal/rpc/group/create_group.go | 43 +++++------------------------- 3 files changed, 11 insertions(+), 40 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 369973051..a85c10dbf 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 369973051405db1102fd1b99a0226ab79b9922e0 +Subproject commit a85c10dbffbb797b5b2091e209ff67a5534b9bfc diff --git a/internal/rpc/chat/send_msg.go b/internal/rpc/chat/send_msg.go index cc865e66a..f72404789 100644 --- a/internal/rpc/chat/send_msg.go +++ b/internal/rpc/chat/send_msg.go @@ -226,9 +226,9 @@ func CreateGroupNotification(sendID string, creator im_mysql_model.User, group i msg.Content = utils.StructToJsonString(tip) var offlinePushInfo open_im_sdk.OfflinePushInfo - offlinePushInfo.Title = "create group title" - offlinePushInfo.Desc = "create group desc" - offlinePushInfo.Ext = "create group ext" + offlinePushInfo.Title = config.Config.Notification.CreateGroup.Title + offlinePushInfo.Desc = config.Config.Notification.CreateGroup.Desc + offlinePushInfo.Ext = config.Config.Notification.CreateGroup.Ext Notification(&msg, false, offlinePushInfo) } diff --git a/internal/rpc/group/create_group.go b/internal/rpc/group/create_group.go index e36048304..826a08615 100644 --- a/internal/rpc/group/create_group.go +++ b/internal/rpc/group/create_group.go @@ -1,8 +1,6 @@ package group import ( - "Open_IM/internal/push/content_struct" - "Open_IM/internal/push/logic" "Open_IM/internal/rpc/chat" "Open_IM/pkg/common/config" "Open_IM/pkg/common/constant" @@ -11,9 +9,7 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/common/token_verify" "Open_IM/pkg/grpc-etcdv3/getcdv3" - pbChat "Open_IM/pkg/proto/chat" pbGroup "Open_IM/pkg/proto/group" - open_im_sdk "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" "google.golang.org/grpc" @@ -71,7 +67,7 @@ func (s *groupServer) Run() { } func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq) (*pbGroup.CreateGroupResp, error) { - log.InfoByArgs("rpc create group is server,args=%s", req.String()) + log.NewInfo(req.OperationID, "rpc create group is server,args=%s", req.String()) var ( groupId string ) @@ -133,49 +129,24 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } } - if isMagagerFlag == 1 { - - //type NotificationContent struct { - // IsDisplay int32 `json:"isDisplay"` - // DefaultTips string `json:"defaultTips"` - // Detail string `json:"detail"` - //} n := NotificationContent{ - // IsDisplay: 1, - // DefaultTips: "You have joined the group chat:" + createGroupResp.Data.GroupName, - // Detail: createGroupResp.Data.GroupId, - // } - - ////Push message when create group chat - n := content_struct.NotificationContent{1, req.GroupName, groupId} - logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{ - SendID: claims.UID, - RecvID: groupId, - Content: n.ContentToString(), - SendTime: utils.GetCurrentTimestampByNano(), - MsgFrom: constant.SysMsgType, //Notification message identification - ContentType: constant.CreateGroupTip, //Add friend flag - SessionType: constant.GroupChatType, - OperationID: req.OperationID, - }) - } - - var tip open_im_sdk.CreateGroupTip groupInfo, err := im_mysql_model.FindGroupInfoByGroupId(groupId) if err != nil { + log.NewError(req.OperationID, "FindGroupInfoByGroupId failed ", groupId) return &pbGroup.CreateGroupResp{ErrorCode: constant.ErrCreateGroup.ErrCode, ErrorMsg: constant.ErrCreateGroup.ErrMsg}, nil } creatorInfo, err := im_mysql_model.FindUserByUID(claims.UID) if err != nil { - + log.NewError(req.OperationID, "FindUserByUID failed ", claims.UID) + return &pbGroup.CreateGroupResp{ErrorCode: constant.ErrCreateGroup.ErrCode, ErrorMsg: constant.ErrCreateGroup.ErrMsg}, nil } memberList, err := im_mysql_model.FindGroupMemberListByGroupId(groupId) if err != nil { - + log.NewError(req.OperationID, "FindGroupMemberListByGroupId failed ", groupId) } - chat.CreateGroupNotification(claims.UID, *creatorInfo, *groupInfo, memberList) - log.Info(req.Token, req.OperationID, "rpc create group success return") + log.NewInfo(req.OperationID, "creator, group, member list: ", *creatorInfo, *groupInfo, memberList) + chat.CreateGroupNotification(claims.UID, *creatorInfo, *groupInfo, memberList) return &pbGroup.CreateGroupResp{GroupID: groupId}, nil }