diff --git a/config/config.yaml b/config/config.yaml index e11407c5c..628192e4f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -481,6 +481,30 @@ notification: defaultTips: tips: "group member info set" + groupMemberSetToOrdinaryUser: + conversation: + reliabilityLevel: 3 + unreadCount: false + offlinePush: + switch: false + title: "groupMemberSetToOrdinaryUser title" + desc: "groupMemberSetToOrdinaryUser desc" + ext: "groupMemberSetToOrdinaryUser ext" + defaultTips: + tips: "was set to ordinaryUser" + + groupMemberSetToAdmin: + conversation: + reliabilityLevel: 3 + unreadCount: false + offlinePush: + switch: false + title: "groupMemberSetToAdmin title" + desc: "groupMemberSetToAdmin desc" + ext: "groupMemberSetToAdmin ext" + defaultTips: + tips: "was set to admin" + #############################organization################################# organizationChanged: conversation: diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index 22835fcd0..5519135b3 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -266,7 +266,7 @@ func ManagementBatchSendMsg(c *gin.Context) { continue } if rpcResp.ErrCode != 0 { - log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", pbData) + log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", pbData, rpcResp) resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID) continue } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 60127c425..d8567bcc4 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -1648,7 +1648,16 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error() return resp, nil } - chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) + if req.RoleLevel != nil { + switch req.RoleLevel.Value { + case constant.GroupOrdinaryUsers: + chat.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToOrdinaryUserNotification) + case constant.GroupAdmin, constant.GroupOwner: + chat.GroupMemberRoleLevelChangeNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, constant.GroupMemberSetToAdminNotification) + } + } else { + chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) + } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) return resp, nil } diff --git a/internal/rpc/msg/conversation_notification.go b/internal/rpc/msg/conversation_notification.go index 5c39ea06a..b43db7959 100644 --- a/internal/rpc/msg/conversation_notification.go +++ b/internal/rpc/msg/conversation_notification.go @@ -49,12 +49,6 @@ func ConversationSetPrivateNotification(operationID, sendID, recvID string, isPr } var tips open_im_sdk.TipsComm var tipsMsg string - //var senderName string - //senderName, err := im_mysql_model.GetUserNameByUserID(sendID) - //if err != nil { - // log.NewError(operationID, utils.GetSelfFuncName(), err.Error()) - // senderName = sendID - //} if isPrivateChat == true { tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.OpenTips } else { diff --git a/internal/rpc/msg/group_notification.go b/internal/rpc/msg/group_notification.go index e8a29b117..83ee39ba3 100644 --- a/internal/rpc/msg/group_notification.go +++ b/internal/rpc/msg/group_notification.go @@ -170,7 +170,10 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips case constant.GroupMemberInfoSetNotification: tips.DefaultTips = toNickname + "" + cn.GroupMemberInfoSet.DefaultTips.Tips - + case constant.GroupMemberSetToAdminNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToAdmin.DefaultTips.Tips + case constant.GroupMemberSetToOrdinaryUserNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips default: log.Error(operationID, "contentType failed ", contentType) return @@ -311,6 +314,28 @@ func GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberU groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID) } +func GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) { + if notificationType != constant.GroupMemberSetToAdminNotification || notificationType != constant.GroupOrdinaryUsers { + log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType) + return + } + tips := open_im_sdk.GroupMemberInfoSetTips{Group: &open_im_sdk.GroupInfo{}, + OpUser: &open_im_sdk.GroupMemberFullInfo{}, ChangedUser: &open_im_sdk.GroupMemberFullInfo{}} + if err := setGroupInfo(groupID, tips.Group); err != nil { + log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID) + return + } + if err := setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil { + log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID) + return + } + if err := setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(notificationType, &tips, opUserID, groupID, "", operationID) +} + func GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) { tips := open_im_sdk.GroupMemberCancelMutedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}} diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index b38e573e2..72d737453 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -51,6 +51,9 @@ type MsgCallBackResp struct { func userRelationshipVerification(data *pbChat.SendMsgReq) (bool, int32, string) { if data.MsgData.SessionType == constant.SingleChatType { + if utils.IsContain(data.MsgData.SendID, config.Config.Manager.AppManagerUid) { + return true, 0, "" + } log.NewDebug(data.OperationID, config.Config.MessageVerify.FriendVerify) reqGetBlackIDListFromCache := &cacheRpc.GetBlackIDListFromCacheReq{UserID: data.MsgData.RecvID, OperationID: data.OperationID} etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 2b9a4d891..8250199a7 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -339,6 +339,16 @@ type config struct { OfflinePush POfflinePush `yaml:"offlinePush"` DefaultTips PDefaultTips `yaml:"defaultTips"` } `yaml:"groupMemberInfoSet"` + GroupMemberSetToAdmin struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupMemberSetToAdmin"` + GroupMemberSetToOrdinary struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupMemberSetToOrdinaryUser"` OrganizationChanged struct { Conversation PConversation `yaml:"conversation"` OfflinePush POfflinePush `yaml:"offlinePush"` diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 1e23ebefa..bae1f15b9 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -67,22 +67,24 @@ const ( GroupNotificationBegin = 1500 - GroupCreatedNotification = 1501 - GroupInfoSetNotification = 1502 - JoinGroupApplicationNotification = 1503 - MemberQuitNotification = 1504 - GroupApplicationAcceptedNotification = 1505 - GroupApplicationRejectedNotification = 1506 - GroupOwnerTransferredNotification = 1507 - MemberKickedNotification = 1508 - MemberInvitedNotification = 1509 - MemberEnterNotification = 1510 - GroupDismissedNotification = 1511 - GroupMemberMutedNotification = 1512 - GroupMemberCancelMutedNotification = 1513 - GroupMutedNotification = 1514 - GroupCancelMutedNotification = 1515 - GroupMemberInfoSetNotification = 1516 + GroupCreatedNotification = 1501 + GroupInfoSetNotification = 1502 + JoinGroupApplicationNotification = 1503 + MemberQuitNotification = 1504 + GroupApplicationAcceptedNotification = 1505 + GroupApplicationRejectedNotification = 1506 + GroupOwnerTransferredNotification = 1507 + MemberKickedNotification = 1508 + MemberInvitedNotification = 1509 + MemberEnterNotification = 1510 + GroupDismissedNotification = 1511 + GroupMemberMutedNotification = 1512 + GroupMemberCancelMutedNotification = 1513 + GroupMutedNotification = 1514 + GroupCancelMutedNotification = 1515 + GroupMemberInfoSetNotification = 1516 + GroupMemberSetToAdminNotification = 1517 + GroupMemberSetToOrdinaryUserNotification = 1518 SignalingNotificationBegin = 1600 SignalingNotification = 1601