You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/msg/group_notification.go

590 lines
25 KiB

3 years ago
package msg
import (
3 years ago
"Open_IM/pkg/common/config"
3 years ago
"Open_IM/pkg/common/constant"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
utils2 "Open_IM/pkg/common/utils"
pbGroup "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
3 years ago
"github.com/golang/protobuf/jsonpb"
3 years ago
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/types/known/wrapperspb"
3 years ago
)
//message GroupCreatedTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo Creator = 2;
// repeated GroupMemberFullInfo MemberList = 3;
// uint64 OperationTime = 4;
//} creator->group
func setOpUserInfo(opUserID, groupID string, groupMemberInfo *open_im_sdk.GroupMemberFullInfo) error {
3 years ago
if token_verify.IsManagerUserID(opUserID) {
3 years ago
u, err := imdb.GetUserByUserID(opUserID)
if err != nil {
return utils.Wrap(err, "GetUserByUserID failed")
}
utils.CopyStructFields(groupMemberInfo, u)
3 years ago
groupMemberInfo.GroupID = groupID
3 years ago
} else {
u, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, opUserID)
3 years ago
if err == nil {
if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, u); err != nil {
return utils.Wrap(err, "")
}
3 years ago
}
3 years ago
user, err := imdb.GetUserByUserID(opUserID)
if err != nil {
3 years ago
return utils.Wrap(err, "")
}
3 years ago
groupMemberInfo.GroupID = groupID
groupMemberInfo.UserID = user.UserID
groupMemberInfo.Nickname = user.Nickname
groupMemberInfo.AppMangerLevel = user.AppMangerLevel
groupMemberInfo.FaceURL = user.FaceURL
3 years ago
}
return nil
}
func setGroupInfo(groupID string, groupInfo *open_im_sdk.GroupInfo) error {
group, err := imdb.GetGroupInfoByGroupID(groupID)
if err != nil {
return utils.Wrap(err, "GetGroupInfoByGroupID failed")
}
err = utils2.GroupDBCopyOpenIM(groupInfo, group)
if err != nil {
return utils.Wrap(err, "GetGroupMemberNumByGroupID failed")
}
return nil
}
func setGroupMemberInfo(groupID, userID string, groupMemberInfo *open_im_sdk.GroupMemberFullInfo) error {
groupMember, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID)
3 years ago
if err == nil {
return utils.Wrap(utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember), "")
3 years ago
}
3 years ago
user, err := imdb.GetUserByUserID(userID)
if err != nil {
3 years ago
return utils.Wrap(err, "")
}
3 years ago
groupMemberInfo.GroupID = groupID
groupMemberInfo.UserID = user.UserID
groupMemberInfo.Nickname = user.Nickname
groupMemberInfo.AppMangerLevel = user.AppMangerLevel
groupMemberInfo.FaceURL = user.FaceURL
3 years ago
return nil
}
3 years ago
func setGroupOwnerInfo(groupID string, groupMemberInfo *open_im_sdk.GroupMemberFullInfo) error {
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(groupID)
if err != nil {
return utils.Wrap(err, "")
}
if err = utils2.GroupMemberDBCopyOpenIM(groupMemberInfo, groupMember); err != nil {
return utils.Wrap(err, "")
}
return nil
}
func setPublicUserInfo(userID string, publicUserInfo *open_im_sdk.PublicUserInfo) error {
user, err := imdb.GetUserByUserID(userID)
if err != nil {
return utils.Wrap(err, "")
}
utils2.UserDBCopyOpenIMPublicUser(publicUserInfo, user)
return nil
}
func groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) {
2 years ago
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID)
3 years ago
var err error
var tips open_im_sdk.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
return
}
3 years ago
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
2 years ago
var nickname string
2 years ago
from, err := imdb.GetUserByUserID(sendID)
if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID)
}
if from != nil {
nickname = from.Nickname
3 years ago
}
2 years ago
3 years ago
to, err := imdb.GetUserByUserID(recvUserID)
if err != nil {
2 years ago
log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID)
3 years ago
}
toNickname := ""
3 years ago
if to != nil {
3 years ago
toNickname = to.Nickname
}
3 years ago
cn := config.Config.Notification
switch contentType {
case constant.GroupCreatedNotification:
3 years ago
tips.DefaultTips = nickname + " " + cn.GroupCreated.DefaultTips.Tips
3 years ago
case constant.GroupInfoSetNotification:
3 years ago
tips.DefaultTips = nickname + " " + cn.GroupInfoSet.DefaultTips.Tips
3 years ago
case constant.JoinGroupApplicationNotification:
3 years ago
tips.DefaultTips = nickname + " " + cn.JoinGroupApplication.DefaultTips.Tips
3 years ago
case constant.MemberQuitNotification:
3 years ago
tips.DefaultTips = nickname + " " + cn.MemberQuit.DefaultTips.Tips
case constant.GroupApplicationAcceptedNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupApplicationAccepted.DefaultTips.Tips
case constant.GroupApplicationRejectedNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupApplicationRejected.DefaultTips.Tips
case constant.GroupOwnerTransferredNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupOwnerTransferred.DefaultTips.Tips
case constant.MemberKickedNotification: //
tips.DefaultTips = toNickname + " " + cn.MemberKicked.DefaultTips.Tips
case constant.MemberInvitedNotification: //
tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips
3 years ago
case constant.MemberEnterNotification:
3 years ago
tips.DefaultTips = toNickname + " " + cn.MemberEnter.DefaultTips.Tips
case constant.GroupDismissedNotification:
tips.DefaultTips = toNickname + "" + cn.GroupDismissed.DefaultTips.Tips
3 years ago
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
case constant.GroupMemberInfoSetNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMemberInfoSet.DefaultTips.Tips
2 years ago
case constant.GroupMemberSetToAdminNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToAdmin.DefaultTips.Tips
case constant.GroupMemberSetToOrdinaryUserNotification:
tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips
3 years ago
default:
log.Error(operationID, "contentType failed ", contentType)
return
}
var n NotificationMsg
n.SendID = sendID
if groupID != "" {
n.RecvID = groupID
2 years ago
group, err := imdb.GetGroupInfoByGroupID(groupID)
if err != nil {
log.NewError(operationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID)
}
switch group.GroupType {
case constant.NormalGroup:
n.SessionType = constant.GroupChatType
default:
n.SessionType = constant.SuperGroupChatType
}
3 years ago
} else {
n.RecvID = recvUserID
n.SessionType = constant.SingleChatType
}
n.ContentType = contentType
n.OperationID = operationID
n.Content, err = proto.Marshal(&tips)
if err != nil {
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
return
}
Notification(&n)
}
3 years ago
//创建群后调用
3 years ago
func GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) {
3 years ago
GroupCreatedTips := open_im_sdk.GroupCreatedTips{Group: &open_im_sdk.GroupInfo{},
3 years ago
OpUser: &open_im_sdk.GroupMemberFullInfo{}, GroupOwnerUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil {
log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser)
3 years ago
return
3 years ago
}
err := setGroupInfo(groupID, GroupCreatedTips.Group)
if err != nil {
3 years ago
log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group)
return
}
imdb.GetGroupOwnerInfoByGroupID(groupID)
if err := setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID)
3 years ago
return
}
for _, v := range initMemberList {
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
3 years ago
if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v)
continue
}
3 years ago
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
if len(GroupCreatedTips.MemberList) == constant.MaxNotificationNum {
break
}
3 years ago
}
3 years ago
groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID)
}
//群信息改变后掉用
2 years ago
//groupName := ""
// notification := ""
// introduction := ""
// faceURL := ""
func GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) {
3 years ago
GroupInfoChangedTips := open_im_sdk.GroupInfoSetTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
return
}
2 years ago
GroupInfoChangedTips.Group.GroupName = groupName
GroupInfoChangedTips.Group.Notification = notification
GroupInfoChangedTips.Group.Introduction = introduction
GroupInfoChangedTips.Group.FaceURL = faceURL
2 years ago
if needVerification != nil {
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
}
3 years ago
if err := setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
return
}
groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
3 years ago
}
3 years ago
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 GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) {
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(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID)
}
2 years ago
func GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) {
2 years ago
if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification {
2 years ago
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)
}
3 years ago
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)
}
3 years ago
//message ReceiveJoinApplicationTips{
// GroupInfo Group = 1;
// PublicUserInfo Applicant = 2;
// string Reason = 3;
//} apply->all managers GroupID string `protobuf:"bytes,1,opt,name=GroupID" json:"GroupID,omitempty"`
// ReqMessage string `protobuf:"bytes,2,opt,name=ReqMessage" json:"ReqMessage,omitempty"`
// OpUserID string `protobuf:"bytes,3,opt,name=OpUserID" json:"OpUserID,omitempty"`
// OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"`
//申请进群后调用
3 years ago
func JoinGroupApplicationNotification(req *pbGroup.JoinGroupReq) {
3 years ago
JoinGroupApplicationTips := open_im_sdk.JoinGroupApplicationTips{Group: &open_im_sdk.GroupInfo{}, Applicant: &open_im_sdk.PublicUserInfo{}}
err := setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
if err != nil {
3 years ago
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
3 years ago
return
}
3 years ago
if err = setPublicUserInfo(req.OpUserID, JoinGroupApplicationTips.Applicant); err != nil {
log.Error(req.OperationID, "setPublicUserInfo failed ", err.Error(), req.OpUserID)
3 years ago
return
}
3 years ago
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
3 years ago
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
if err != nil {
log.NewError(req.OperationID, "GetOwnerManagerByGroupId failed ", err.Error(), req.GroupID)
return
}
for _, v := range managerList {
3 years ago
groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, req.OpUserID, "", v.UserID, req.OperationID)
log.NewInfo(req.OperationID, "Notification ", v)
3 years ago
}
}
3 years ago
func MemberQuitNotification(req *pbGroup.QuitGroupReq) {
MemberQuitTips := open_im_sdk.MemberQuitTips{Group: &open_im_sdk.GroupInfo{}, QuitUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil {
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
return
}
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberQuitTips.QuitUser); err != nil {
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID, req.GroupID)
return
}
groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, req.GroupID, "", req.OperationID)
3 years ago
// groupNotification(constant.MemberQuitNotification, &MemberQuitTips, req.OpUserID, "", req.OpUserID, req.OperationID)
3 years ago
}
3 years ago
//message ApplicationProcessedTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo OpUser = 2;
// int32 Result = 3;
// string Reason = 4;
//}
//处理进群请求后调用
3 years ago
func GroupApplicationAcceptedNotification(req *pbGroup.GroupApplicationResponseReq) {
GroupApplicationAcceptedTips := open_im_sdk.GroupApplicationAcceptedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
if err := setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil {
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationAcceptedTips.Group)
3 years ago
return
}
3 years ago
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil {
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationAcceptedTips.OpUser)
3 years ago
return
}
3 years ago
groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", req.FromUserID, req.OperationID)
}
3 years ago
3 years ago
func GroupApplicationRejectedNotification(req *pbGroup.GroupApplicationResponseReq) {
GroupApplicationRejectedTips := open_im_sdk.GroupApplicationRejectedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
if err := setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil {
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, GroupApplicationRejectedTips.Group)
return
}
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil {
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID, GroupApplicationRejectedTips.OpUser)
return
}
groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, req.OpUserID, "", req.FromUserID, req.OperationID)
3 years ago
}
3 years ago
func GroupOwnerTransferredNotification(req *pbGroup.TransferGroupOwnerReq) {
GroupOwnerTransferredTips := open_im_sdk.GroupOwnerTransferredTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}, NewGroupOwner: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil {
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
3 years ago
return
}
3 years ago
if err := setOpUserInfo(req.OpUserID, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil {
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID)
3 years ago
return
}
3 years ago
if err := setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil {
log.Error(req.OperationID, "setGroupMemberInfo failed", req.GroupID, req.NewOwnerUserID)
return
3 years ago
}
3 years ago
groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, req.OpUserID, req.GroupID, "", req.OperationID)
3 years ago
}
3 years ago
func GroupDismissedNotification(req *pbGroup.DismissGroupReq) {
tips := open_im_sdk.GroupDismissedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(req.GroupID, tips.Group); err != nil {
log.NewError(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
return
}
if err := setOpUserInfo(req.OpUserID, req.GroupID, tips.OpUser); err != nil {
log.Error(req.OperationID, "setOpUserInfo failed", req.OpUserID, req.GroupID)
return
}
groupNotification(constant.GroupDismissedNotification, &tips, req.OpUserID, req.GroupID, "", req.OperationID)
}
3 years ago
//message MemberKickedTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo OpUser = 2;
// GroupMemberFullInfo KickedUser = 3;
// uint64 OperationTime = 4;
//}
//被踢后调用
func MemberKickedNotification(req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) {
MemberKickedTips := open_im_sdk.MemberKickedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
3 years ago
if err := setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil {
3 years ago
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID)
3 years ago
return
}
if err := setOpUserInfo(req.OpUserID, req.GroupID, MemberKickedTips.OpUser); err != nil {
3 years ago
log.Error(req.OperationID, "setOpUserInfo failed ", err.Error(), req.OpUserID)
3 years ago
return
}
3 years ago
for _, v := range kickedUserIDList {
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
3 years ago
if err := setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil {
log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.GroupID, v)
continue
}
3 years ago
MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
}
3 years ago
groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, req.GroupID, "", req.OperationID)
3 years ago
//
//for _, v := range kickedUserIDList {
// groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID)
//}
3 years ago
}
3 years ago
//message MemberInvitedTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo OpUser = 2;
// GroupMemberFullInfo InvitedUser = 3;
// uint64 OperationTime = 4;
3 years ago
//}
3 years ago
//被邀请进群后调用
func MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) {
MemberInvitedTips := open_im_sdk.MemberInvitedTips{Group: &open_im_sdk.GroupInfo{}, OpUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, MemberInvitedTips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
3 years ago
return
}
3 years ago
if err := setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil {
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
3 years ago
return
}
3 years ago
for _, v := range invitedUserIDList {
var groupMemberInfo open_im_sdk.GroupMemberFullInfo
if err := setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID)
continue
}
MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo)
}
groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID)
3 years ago
}
3 years ago
//message GroupInfoChangedTips{
// int32 ChangedType = 1; //bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl
// GroupInfo Group = 2;
// GroupMemberFullInfo OpUser = 3;
//}
3 years ago
//message MemberLeaveTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo LeaverUser = 2;
// uint64 OperationTime = 3;
//}
//群成员退群后调用
//message MemberEnterTips{
// GroupInfo Group = 1;
// GroupMemberFullInfo EntrantUser = 2;
// uint64 OperationTime = 3;
//}
//群成员主动申请进群,管理员同意后调用,
func MemberEnterNotification(req *pbGroup.GroupApplicationResponseReq) {
3 years ago
MemberEnterTips := open_im_sdk.MemberEnterTips{Group: &open_im_sdk.GroupInfo{}, EntrantUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil {
log.Error(req.OperationID, "setGroupInfo failed ", err.Error(), req.GroupID, MemberEnterTips.Group)
3 years ago
return
}
3 years ago
if err := setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil {
log.Error(req.OperationID, "setGroupMemberInfo failed ", err.Error(), req.OpUserID, req.GroupID, MemberEnterTips.EntrantUser)
3 years ago
return
}
3 years ago
groupNotification(constant.MemberEnterNotification, &MemberEnterTips, req.OpUserID, req.GroupID, "", req.OperationID)
}
3 years ago
func MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) {
MemberEnterTips := open_im_sdk.MemberEnterTips{Group: &open_im_sdk.GroupInfo{}, EntrantUser: &open_im_sdk.GroupMemberFullInfo{}}
if err := setGroupInfo(groupID, MemberEnterTips.Group); err != nil {
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group)
return
}
if err := setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil {
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser)
return
}
groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID)
3 years ago
}