mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-14 05:56:00 +08:00
notification
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/chat"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
@@ -18,6 +19,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
log.Error(req.Token, req.OperationID, "err=%s,parse token failed", err.Error())
|
||||
return &pbGroup.CommonResp{ErrorCode: constant.ErrParseToken.ErrCode, ErrorMsg: constant.ErrParseToken.ErrMsg}, nil
|
||||
}
|
||||
|
||||
groupUserInfo, err := im_mysql_model.FindGroupMemberInfoByGroupIdAndUserId(req.GroupID, claims.UID)
|
||||
if err != nil {
|
||||
log.Error("", req.OperationID, "your are not in the group,can not change this group info,err=%s", err.Error())
|
||||
@@ -26,21 +28,33 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if groupUserInfo.AdministratorLevel == constant.OrdinaryMember {
|
||||
return &pbGroup.CommonResp{ErrorCode: constant.ErrSetGroupInfo.ErrCode, ErrorMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
group, err := im_mysql_model.FindGroupInfoByGroupId(req.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "FindGroupInfoByGroupId failed, ", err.Error(), req.GroupID)
|
||||
return &pbGroup.CommonResp{ErrorCode: constant.ErrSetGroupInfo.ErrCode, ErrorMsg: constant.ErrAccess.ErrMsg}, nil
|
||||
}
|
||||
////bitwise operators: 1:groupName; 10:Notification 100:Introduction; 1000:FaceUrl
|
||||
var changedType int32
|
||||
if group.GroupName != req.GroupName && req.GroupName != "" {
|
||||
changedType = 1
|
||||
}
|
||||
if group.Notification != req.Notification && req.Notification != "" {
|
||||
changedType = changedType | (1 << 1)
|
||||
}
|
||||
if group.Introduction != req.Introduction && req.Introduction != "" {
|
||||
changedType = changedType | (1 << 2)
|
||||
}
|
||||
if group.FaceUrl != req.FaceUrl && req.FaceUrl != "" {
|
||||
changedType = changedType | (1 << 3)
|
||||
}
|
||||
//only administrators can set group information
|
||||
if err = im_mysql_model.SetGroupInfo(req.GroupID, req.GroupName, req.Introduction, req.Notification, req.FaceUrl, ""); err != nil {
|
||||
return &pbGroup.CommonResp{ErrorCode: constant.ErrSetGroupInfo.ErrCode, ErrorMsg: constant.ErrSetGroupInfo.ErrMsg}, nil
|
||||
}
|
||||
////Push message when set group info
|
||||
//jsonInfo, _ := json.Marshal(req)
|
||||
//logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
// SendID: claims.UID,
|
||||
// RecvID: req.GroupID,
|
||||
// Content: string(jsonInfo),
|
||||
// SendTime: utils.GetCurrentTimestampBySecond(),
|
||||
// MsgFrom: constant.SysMsgType,
|
||||
// ContentType: constant.SetGroupInfoTip,
|
||||
// SessionType: constant.GroupChatType,
|
||||
// OperationID: req.OperationID,
|
||||
//})
|
||||
|
||||
if changedType != 0 {
|
||||
chat.GroupInfoChangedNotification(req.OperationID, claims.UID, changedType, group, groupUserInfo)
|
||||
}
|
||||
|
||||
return &pbGroup.CommonResp{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user