From fe4b534b781ad6c9ac77b21e92fdc6b06dcefc20 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Tue, 29 Mar 2022 16:04:15 +0800 Subject: [PATCH] mute group --- cmd/Open-IM-SDK-Core | 2 +- config/config.yaml | 50 ++++++++++++++++++ internal/rpc/group/group.go | 6 ++- internal/rpc/msg/group_notification.go | 73 ++++++++++++++++++++++++++ internal/rpc/msg/send_msg.go | 32 +++++++++++ pkg/common/config/config.go | 24 +++++++++ pkg/common/constant/constant.go | 5 +- 7 files changed, 188 insertions(+), 4 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index a19440c3d..a6b33ab9d 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit a19440c3d6e6504655934cc432d8420bb1909816 +Subproject commit a6b33ab9d277ef82e1e0e12c4affb49b53758735 diff --git a/config/config.yaml b/config/config.yaml index 7d864283c..a801d7c57 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -366,6 +366,56 @@ notification: ext: "groupDismissed ext" defaultTips: tips: "group dismissed" + + + groupMuted: + conversation: + reliabilityLevel: 3 + unreadCount: true + offlinePush: + switch: false + title: "groupMuted title" + desc: "groupMuted desc" + ext: "groupMuted ext" + defaultTips: + tips: "group Muted" + + groupCancelMuted: + conversation: + reliabilityLevel: 3 + unreadCount: true + offlinePush: + switch: false + title: "groupCancelMuted title" + desc: "groupCancelMuted desc" + ext: "groupCancelMuted ext" + defaultTips: + tips: "group Cancel Muted" + + + groupMemberMuted: + conversation: + reliabilityLevel: 3 + unreadCount: true + offlinePush: + switch: false + title: "groupMemberMuted title" + desc: "groupMemberMuted desc" + ext: "groupMemberMuted ext" + defaultTips: + tips: "group Member Muted" + + groupMemberCancelMuted: + conversation: + reliabilityLevel: 3 + unreadCount: true + offlinePush: + switch: false + title: "groupMemberCancelMuted title" + desc: "groupMemberCancelMuted desc" + ext: "groupMemberCancelMuted ext" + defaultTips: + tips: "group Member Cancel Muted" #############################friend################################# friendApplicationAdded: diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 98198f598..eefbcac9c 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -980,6 +980,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo) return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } + chat.GroupMemberMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID, req.MutedSeconds) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil } @@ -997,6 +998,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo) return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } + chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil } @@ -1012,7 +1014,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted) return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } - chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID) + chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil } @@ -1030,7 +1032,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), groupInfo) return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil } - chat.GroupInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID) + chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID) log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}) return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil } diff --git a/internal/rpc/msg/group_notification.go b/internal/rpc/msg/group_notification.go index f5155889b..d6def3ff2 100644 --- a/internal/rpc/msg/group_notification.go +++ b/internal/rpc/msg/group_notification.go @@ -160,6 +160,14 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips case constant.GroupDismissedNotification: tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips + case constant.GroupMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMuted.DefaultTips.Tips + case constant.GroupCancelMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupCancelMuted.DefaultTips.Tips + case constant.GroupMemberMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberMuted.DefaultTips.Tips + case constant.GroupMemberCancelMutedNotification: + tips.DefaultTips = toNickname + "" + cn.GroupMemberCancelMuted.DefaultTips.Tips default: log.Error(operationID, "contentType failed ", contentType) return @@ -227,6 +235,71 @@ func GroupInfoSetNotification(operationID, opUserID, groupID string) { groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID) } +func GroupMutedNotification(operationID, opUserID, groupID string) { + tips := open_im_sdk.GroupMutedTips{Group: &open_im_sdk.GroupInfo{}, + OpUser: &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 + } + groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupCancelMutedNotification(operationID, opUserID, groupID string) { + tips := open_im_sdk.GroupCancelMutedTips{Group: &open_im_sdk.GroupInfo{}, + OpUser: &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 + } + groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID) +} + +func GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) { + tips := open_im_sdk.GroupMemberMutedTips{Group: &open_im_sdk.GroupInfo{}, + OpUser: &open_im_sdk.GroupMemberFullInfo{}, MutedUser: &open_im_sdk.GroupMemberFullInfo{}} + tips.MutedSeconds = mutedSeconds + 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.MutedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(constant.GroupMemberMutedNotification, &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{}} + 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.MutedUser); err != nil { + log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID) + return + } + groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID) +} + //message ReceiveJoinApplicationTips{ // GroupInfo Group = 1; // PublicUserInfo Applicant = 2; diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 2820bd8ad..de189a048 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -513,6 +513,38 @@ func Notification(n *NotificationMsg) { ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount + + case constant.GroupMutedNotification: + pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount + + case constant.GroupCancelMutedNotification: + pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title + desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount + + case constant.GroupMemberMutedNotification: + pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount + + case constant.GroupMemberCancelMutedNotification: + pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch + title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title + desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc + ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext + reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel + unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount } switch reliabilityLevel { case constant.UnreliableNotification: diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 2a8ec36ff..2a9759cc7 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -270,6 +270,30 @@ type config struct { DefaultTips PDefaultTips `yaml:"defaultTips"` } `yaml:"groupDismissed"` + GroupMuted struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupMuted"` + + GroupCancelMuted struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupCancelMuted"` + + GroupMemberMuted struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupMemberMuted"` + + GroupMemberCancelMuted struct { + Conversation PConversation `yaml:"conversation"` + OfflinePush POfflinePush `yaml:"offlinePush"` + DefaultTips PDefaultTips `yaml:"defaultTips"` + } `yaml:"groupMemberCancelMuted"` + ////////////////////////user/////////////////////// UserInfoUpdated struct { Conversation PConversation `yaml:"conversation"` diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 0a1e38168..a38076e7b 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -79,7 +79,10 @@ const ( MemberInvitedNotification = 1509 MemberEnterNotification = 1510 GroupDismissedNotification = 1511 - GroupMemberInfoChangedNotification = 1512 + GroupMemberMutedNotification = 1512 + GroupMemberCancelMutedNotification = 1513 + GroupMutedNotification = 1514 + GroupCancelMutedNotification = 1515 SignalingNotificationBegin = 1600 SignalingNotification = 1601