mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-27 12:08:52 +08:00
Error code standardization
This commit is contained in:
parent
c5f1c940d8
commit
e1b6e054f0
@ -104,3 +104,7 @@ func (g *GroupChecker) GetGroupMemberInfoMap(ctx context.Context, groupID string
|
||||
return e.UserID
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (g *GroupChecker) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
|
||||
}
|
||||
|
@ -22,12 +22,11 @@ type NotificationMsg struct {
|
||||
MsgFrom int32
|
||||
ContentType int32
|
||||
SessionType int32
|
||||
OperationID string
|
||||
SenderNickname string
|
||||
SenderFaceURL string
|
||||
}
|
||||
|
||||
func (c *Check) Notification(n *NotificationMsg) {
|
||||
func (c *Check) Notification(ctx context.Context, n *NotificationMsg) {
|
||||
var req msg.SendMsgReq
|
||||
var msg sdkws.MsgData
|
||||
var offlineInfo sdkws.OfflinePushInfo
|
||||
@ -284,6 +283,6 @@ func (c *Check) Notification(n *NotificationMsg) {
|
||||
_, err := sendMsg(context.Background(), &req)
|
||||
}
|
||||
|
||||
func sendMsg(ctx context.Context, req *msg.SendMsgReq) (msg.SendMsgResp, error) {
|
||||
func sendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
||||
|
||||
}
|
||||
|
@ -3,21 +3,16 @@ package notification
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
sdkws "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) {
|
||||
log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String())
|
||||
func (c *Check) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) {
|
||||
var err error
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
log.NewError(operationID, "Marshal failed ", err.Error(), m.String())
|
||||
return
|
||||
}
|
||||
marshaler := jsonpb.Marshaler{
|
||||
@ -32,13 +27,11 @@ func (c *Check) SetConversationNotification(operationID, sendID, recvID string,
|
||||
n.ContentType = int32(contentType)
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.OperationID = operationID
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String())
|
||||
return
|
||||
}
|
||||
c.Notification(&n)
|
||||
c.Notification(ctx, &n)
|
||||
}
|
||||
|
||||
// SetPrivate调用
|
||||
@ -57,7 +50,7 @@ func (c *Check) ConversationSetPrivateNotification(ctx context.Context, sendID,
|
||||
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
|
||||
}
|
||||
tips.DefaultTips = tipsMsg
|
||||
c.SetConversationNotification(tracelog.GetOperationID(ctx), sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips)
|
||||
c.SetConversationNotification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, tips)
|
||||
}
|
||||
|
||||
// 会话改变
|
||||
@ -68,11 +61,11 @@ func (c *Check) ConversationChangeNotification(ctx context.Context, userID strin
|
||||
}
|
||||
var tips sdkws.TipsComm
|
||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||
c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips)
|
||||
c.SetConversationNotification(ctx, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, tips)
|
||||
}
|
||||
|
||||
// 会话未读数同步
|
||||
func (c *Check) ConversationUnreadChangeNotification(context context.Context, userID, conversationID string, updateUnreadCountTime int64) {
|
||||
func (c *Check) ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, updateUnreadCountTime int64) {
|
||||
|
||||
ConversationChangedTips := &sdkws.ConversationUpdateTips{
|
||||
UserID: userID,
|
||||
@ -81,5 +74,5 @@ func (c *Check) ConversationUnreadChangeNotification(context context.Context, us
|
||||
}
|
||||
var tips sdkws.TipsComm
|
||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||
c.SetConversationNotification(tracelog.GetOperationID(ctx), userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips)
|
||||
c.SetConversationNotification(ctx, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, tips)
|
||||
}
|
||||
|
@ -4,31 +4,26 @@ import (
|
||||
"Open_IM/internal/common/check"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tracelog"
|
||||
pbFriend "Open_IM/pkg/proto/friend"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func getFromToUserNickname(userCheck *check.UserCheck, fromUserID, toUserID string) (string, string, error) {
|
||||
users, err := userCheck.GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true)
|
||||
func (c *Check) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
||||
users, err := c.user.GetUsersInfoMap(ctx, []string{fromUserID, toUserID}, true)
|
||||
if err != nil {
|
||||
return "", "", nil
|
||||
}
|
||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||
}
|
||||
|
||||
func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) {
|
||||
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType)
|
||||
func (c *Check) friendNotification(ctx context.Context, fromUserID, toUserID string, contentType int32, m proto.Message) {
|
||||
var err error
|
||||
var tips sdkws.TipsComm
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
||||
return
|
||||
}
|
||||
|
||||
@ -40,9 +35,8 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
||||
|
||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||
|
||||
fromUserNickname, toUserNickname, err := getFromToUserNickname(fromUserID, toUserID)
|
||||
fromUserNickname, toUserNickname, err := c.getFromToUserNickname(ctx, fromUserID, toUserID)
|
||||
if err != nil {
|
||||
log.Error(operationID, "getFromToUserNickname failed ", err.Error(), fromUserID, toUserID)
|
||||
return
|
||||
}
|
||||
cn := config.Config.Notification
|
||||
@ -68,7 +62,6 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
||||
case constant.FriendInfoUpdatedNotification:
|
||||
tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname
|
||||
default:
|
||||
log.Error(operationID, "contentType failed ", contentType)
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,20 +71,18 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.OperationID = operationID
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
||||
return
|
||||
}
|
||||
Notification(&n)
|
||||
c.Notification(ctx, &n)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) {
|
||||
FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips)
|
||||
c.friendNotification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
||||
@ -99,7 +90,7 @@ func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pb
|
||||
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
||||
c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
||||
@ -107,12 +98,12 @@ func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *p
|
||||
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
||||
c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) {
|
||||
friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
||||
user, err := check.NewUserCheck().GetUsersInfos(context.Background(), []string{opUserID}, true)
|
||||
user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -126,44 +117,44 @@ func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUser
|
||||
return
|
||||
}
|
||||
friendAddedTips.Friend = friend
|
||||
friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
||||
c.friendNotification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) {
|
||||
friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips)
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) {
|
||||
friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
||||
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
||||
friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
||||
c.friendNotification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
||||
}
|
||||
|
||||
func (c *Check) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) {
|
||||
blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
blackAddedTips.FromToUserID.ToUserID = req.BlackUserID
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips)
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips)
|
||||
}
|
||||
|
||||
func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID
|
||||
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||
}
|
||||
|
||||
// send to myself
|
||||
func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) {
|
||||
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||
friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||
c.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
|
||||
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||
friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||
c.friendNotification(ctx, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||
}
|
||||
|
@ -15,9 +15,10 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
func (c *Check) setOpUserInfo(ctx context.Context, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
opUserID := tracelog.GetOpUserID(ctx)
|
||||
if tokenverify.IsManagerUserID(opUserID) {
|
||||
user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true)
|
||||
user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -28,12 +29,12 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G
|
||||
groupMemberInfo.FaceURL = user[0].FaceURL
|
||||
return nil
|
||||
}
|
||||
u, err := c.group.GetGroupMemberInfo(context.Background(), groupID, opUserID)
|
||||
u, err := c.group.GetGroupMemberInfo(ctx, groupID, opUserID)
|
||||
if err == nil {
|
||||
*groupMemberInfo = *u
|
||||
return nil
|
||||
}
|
||||
user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true)
|
||||
user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -46,8 +47,8 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error {
|
||||
group, err := c.group.GetGroupInfos(context.Background(), []string{groupID}, true)
|
||||
func (c *Check) setGroupInfo(ctx context.Context, groupID string, groupInfo *sdkws.GroupInfo) error {
|
||||
group, err := c.group.GetGroupInfos(ctx, []string{groupID}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -55,13 +56,13 @@ func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, userID)
|
||||
func (c *Check) setGroupMemberInfo(ctx context.Context, groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, userID)
|
||||
if err == nil {
|
||||
*groupMemberInfo = *groupMember
|
||||
return nil
|
||||
}
|
||||
user, err := c.user.GetUsersInfos(context.Background(), []string{userID}, true)
|
||||
user, err := c.user.GetUsersInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -73,12 +74,12 @@ func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkw
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
group, err := c.group.GetGroupInfo(context.Background(), groupID)
|
||||
func (c *Check) setGroupOwnerInfo(ctx context.Context, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||
group, err := c.group.GetGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, group.OwnerUserID)
|
||||
groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, group.OwnerUserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -86,8 +87,8 @@ func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMe
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error {
|
||||
user, err := c.user.GetPublicUserInfos(context.Background(), []string{userID}, true)
|
||||
func (c *Check) setPublicUserInfo(ctx context.Context, userID string, publicUserInfo *sdkws.PublicUserInfo) error {
|
||||
user, err := c.user.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -95,13 +96,11 @@ func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUse
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) {
|
||||
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID)
|
||||
func (c *Check) groupNotification(ctx context.Context, contentType int32, m proto.Message, sendID, groupID, recvUserID string) {
|
||||
var err error
|
||||
var tips sdkws.TipsComm
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
||||
return
|
||||
}
|
||||
marshaler := jsonpb.Marshaler{
|
||||
@ -113,14 +112,14 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
||||
var nickname, toNickname string
|
||||
if sendID != "" {
|
||||
|
||||
from, err := c.user.GetUsersInfos(context.Background(), []string{sendID}, true)
|
||||
from, err := c.user.GetUsersInfos(ctx, []string{sendID}, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
nickname = from[0].Nickname
|
||||
}
|
||||
if recvUserID != "" {
|
||||
to, err := c.user.GetUsersInfos(context.Background(), []string{recvUserID}, true)
|
||||
to, err := c.user.GetUsersInfos(ctx, []string{recvUserID}, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -166,7 +165,6 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
||||
case constant.GroupMemberSetToOrdinaryUserNotification:
|
||||
tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips
|
||||
default:
|
||||
log.Error(operationID, "contentType failed ", contentType)
|
||||
return
|
||||
}
|
||||
|
||||
@ -175,7 +173,7 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
||||
if groupID != "" {
|
||||
n.RecvID = groupID
|
||||
|
||||
group, err := c.group.GetGroupInfo(context.Background(), groupID)
|
||||
group, err := c.group.GetGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -190,37 +188,31 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
||||
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
|
||||
}
|
||||
c.Notification(&n)
|
||||
c.Notification(ctx, &n)
|
||||
}
|
||||
|
||||
// 创建群后调用
|
||||
func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string, initMemberList []string) {
|
||||
func (c *Check) GroupCreatedNotification(ctx context.Context, groupID string, initMemberList []string) {
|
||||
GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil {
|
||||
log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser)
|
||||
if err := c.setOpUserInfo(ctx, groupID, GroupCreatedTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
err := c.setGroupInfo(groupID, GroupCreatedTips.Group)
|
||||
err := c.setGroupInfo(ctx, groupID, GroupCreatedTips.Group)
|
||||
if err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group)
|
||||
return
|
||||
}
|
||||
|
||||
if err := c.setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
|
||||
log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID)
|
||||
if err := c.setGroupOwnerInfo(ctx, groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range initMemberList {
|
||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||
if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v)
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil {
|
||||
continue
|
||||
}
|
||||
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
||||
@ -228,7 +220,8 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string,
|
||||
break
|
||||
}
|
||||
}
|
||||
c.groupNotification(constant.GroupCreatedNotification, &GroupCreatedTips, opUserID, groupID, "", operationID)
|
||||
|
||||
c.groupNotification(ctx, constant.GroupCreatedNotification, &GroupCreatedTips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
// 群信息改变后掉用
|
||||
@ -237,10 +230,9 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string,
|
||||
// notification := ""
|
||||
// introduction := ""
|
||||
// faceURL := ""
|
||||
func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) {
|
||||
func (c *Check) GroupInfoSetNotification(ctx context.Context, groupID string, groupName, notification, introduction, faceURL string, needVerification *wrapperspb.Int32Value) {
|
||||
GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, GroupInfoChangedTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
GroupInfoChangedTips.Group.GroupName = groupName
|
||||
@ -251,116 +243,102 @@ func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string,
|
||||
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
|
||||
}
|
||||
|
||||
if err := c.setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupInfoSetNotification, &GroupInfoChangedTips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupInfoSetNotification, &GroupInfoChangedTips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupMutedNotification(operationID, opUserID, groupID string) {
|
||||
func (c *Check) GroupMutedNotification(ctx context.Context, groupID string) {
|
||||
tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupCancelMutedNotification(operationID, opUserID, groupID string) {
|
||||
func (c *Check) GroupCancelMutedNotification(ctx context.Context, groupID string) {
|
||||
tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupCancelMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupMemberMutedNotification(operationID, opUserID, groupID, groupMemberUserID string, mutedSeconds uint32) {
|
||||
func (c *Check) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) {
|
||||
tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}}
|
||||
tips.MutedSeconds = mutedSeconds
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupMemberMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupMemberMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupMemberInfoSetNotification(operationID, opUserID, groupID, groupMemberUserID string) {
|
||||
func (c *Check) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) {
|
||||
tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.ChangedUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupMemberInfoSetNotification, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupMemberInfoSetNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupMemberRoleLevelChangeNotification(operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) {
|
||||
func (c *Check) GroupMemberRoleLevelChangeNotification(ctx context.Context, operationID, opUserID, groupID, groupMemberUserID string, notificationType int32) {
|
||||
if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType)
|
||||
return
|
||||
}
|
||||
tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.ChangedUser); err != nil {
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.ChangedUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||
return
|
||||
}
|
||||
c.groupNotification(notificationType, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, notificationType, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupID, groupMemberUserID string) {
|
||||
func (c *Check) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) {
|
||||
tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{},
|
||||
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, tips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, tips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, tips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, tips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.GroupMemberCancelMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
// message ReceiveJoinApplicationTips{
|
||||
@ -376,38 +354,35 @@ func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupI
|
||||
// 申请进群后调用
|
||||
func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) {
|
||||
JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}}
|
||||
err := c.setGroupInfo(req.GroupID, JoinGroupApplicationTips.Group)
|
||||
err := c.setGroupInfo(ctx, req.GroupID, JoinGroupApplicationTips.Group)
|
||||
if err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
if err = c.setPublicUserInfo(tracelog.GetOpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil {
|
||||
if err = c.setPublicUserInfo(ctx, tracelog.GetOpUserID(ctx), JoinGroupApplicationTips.Applicant); err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
||||
|
||||
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
||||
managerList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range managerList {
|
||||
c.groupNotification(constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tracelog.GetOpUserID(ctx), "", v.UserID, utils.OperationID(ctx))
|
||||
|
||||
c.groupNotification(ctx, constant.JoinGroupApplicationNotification, &JoinGroupApplicationTips, tracelog.GetOpUserID(ctx), "", v.UserID)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGroupReq) {
|
||||
MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(req.GroupID, MemberQuitTips.Group); err != nil {
|
||||
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, MemberQuitTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberQuitTips.QuitUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, MemberQuitTips.QuitUser); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.groupNotification(constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.MemberQuitNotification, &MemberQuitTips, tracelog.GetOpUserID(ctx), req.GroupID, "")
|
||||
}
|
||||
|
||||
// message ApplicationProcessedTips{
|
||||
@ -420,75 +395,74 @@ func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGro
|
||||
// 处理进群请求后调用
|
||||
func (c *Check) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||
GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
||||
if err := c.setGroupInfo(req.GroupID, GroupApplicationAcceptedTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, GroupApplicationAcceptedTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, GroupApplicationAcceptedTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx))
|
||||
adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
||||
c.groupNotification(ctx, constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID)
|
||||
adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID)
|
||||
return
|
||||
}
|
||||
for _, v := range adminList {
|
||||
if v.UserID == req.OpUserID {
|
||||
if v.UserID == tracelog.GetOpUserID(ctx) {
|
||||
continue
|
||||
}
|
||||
GroupApplicationAcceptedTips.ReceiverAs = 1
|
||||
c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, req.OpUserID, "", v.UserID, req.OperationID)
|
||||
c.groupNotification(ctx, constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", v.UserID)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Check) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||
GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
||||
if err := c.setGroupInfo(req.GroupID, GroupApplicationRejectedTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, GroupApplicationRejectedTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, GroupApplicationRejectedTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx))
|
||||
adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
||||
c.groupNotification(ctx, constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID)
|
||||
adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range adminList {
|
||||
if v.UserID == req.OpUserID {
|
||||
if v.UserID == tracelog.GetOpUserID(ctx) {
|
||||
continue
|
||||
}
|
||||
GroupApplicationRejectedTips.ReceiverAs = 1
|
||||
c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", v.UserID, tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", v.UserID)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Check) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) {
|
||||
GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(req.GroupID, GroupOwnerTransferredTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, GroupOwnerTransferredTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, GroupOwnerTransferredTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil {
|
||||
if err := c.setGroupMemberInfo(ctx, req.GroupID, req.NewOwnerUserID, GroupOwnerTransferredTips.NewGroupOwner); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.GroupOwnerTransferredNotification, &GroupOwnerTransferredTips, tracelog.GetOpUserID(ctx), req.GroupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.DismissGroupReq) {
|
||||
tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(req.GroupID, tips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, tips.Group); err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, tips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, tips.OpUser); err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.GroupDismissedNotification, &tips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.GroupDismissedNotification, &tips, tracelog.GetOpUserID(ctx), req.GroupID, "")
|
||||
}
|
||||
|
||||
// message MemberKickedTips{
|
||||
@ -501,20 +475,20 @@ func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.Dis
|
||||
// 被踢后调用
|
||||
func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) {
|
||||
MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(req.GroupID, MemberKickedTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, MemberKickedTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(tracelog.GetOpUserID(ctx), req.GroupID, MemberKickedTips.OpUser); err != nil {
|
||||
if err := c.setOpUserInfo(ctx, req.GroupID, MemberKickedTips.OpUser); err != nil {
|
||||
return
|
||||
}
|
||||
for _, v := range kickedUserIDList {
|
||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||
if err := c.setGroupMemberInfo(req.GroupID, v, &groupMemberInfo); err != nil {
|
||||
if err := c.setGroupMemberInfo(ctx, req.GroupID, v, &groupMemberInfo); err != nil {
|
||||
continue
|
||||
}
|
||||
MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
|
||||
}
|
||||
c.groupNotification(constant.MemberKickedNotification, &MemberKickedTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.MemberKickedNotification, &MemberKickedTips, tracelog.GetOpUserID(ctx), req.GroupID, "")
|
||||
//
|
||||
//for _, v := range kickedUserIDList {
|
||||
// groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID)
|
||||
@ -529,48 +503,46 @@ func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickG
|
||||
// }
|
||||
//
|
||||
// 被邀请进群后调用
|
||||
func (c *Check) MemberInvitedNotification(operationID, groupID, opUserID, reason string, invitedUserIDList []string) {
|
||||
func (c *Check) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) {
|
||||
MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, MemberInvitedTips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupInfo(ctx, groupID, MemberInvitedTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil {
|
||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||
if err := c.setOpUserInfo(ctx, groupID, MemberInvitedTips.OpUser); err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
for _, v := range invitedUserIDList {
|
||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||
if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID)
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil {
|
||||
continue
|
||||
}
|
||||
MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo)
|
||||
}
|
||||
c.groupNotification(constant.MemberInvitedNotification, &MemberInvitedTips, opUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.MemberInvitedNotification, &MemberInvitedTips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||
}
|
||||
|
||||
// 群成员主动申请进群,管理员同意后调用,
|
||||
func (c *Check) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||
MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(req.GroupID, MemberEnterTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, req.GroupID, MemberEnterTips.Group); err != nil {
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
if err := c.setGroupMemberInfo(ctx, req.GroupID, req.FromUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, tracelog.GetOpUserID(ctx), req.GroupID, "", tracelog.GetOperationID(ctx))
|
||||
c.groupNotification(ctx, constant.MemberEnterNotification, &MemberEnterTips, tracelog.GetOpUserID(ctx), req.GroupID, "")
|
||||
}
|
||||
|
||||
func (c *Check) MemberEnterDirectlyNotification(groupID string, entrantUserID string, operationID string) {
|
||||
func (c *Check) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string, operationID string) {
|
||||
MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}}
|
||||
if err := c.setGroupInfo(groupID, MemberEnterTips.Group); err != nil {
|
||||
if err := c.setGroupInfo(ctx, groupID, MemberEnterTips.Group); err != nil {
|
||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group)
|
||||
return
|
||||
}
|
||||
if err := c.setGroupMemberInfo(groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
if err := c.setGroupMemberInfo(ctx, groupID, entrantUserID, MemberEnterTips.EntrantUser); err != nil {
|
||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser)
|
||||
return
|
||||
}
|
||||
c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID)
|
||||
c.groupNotification(ctx, constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "")
|
||||
}
|
||||
|
@ -5,11 +5,12 @@ import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) {
|
||||
func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqList []uint32, operationID string) {
|
||||
DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList}
|
||||
c.MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
|
||||
}
|
||||
@ -37,7 +38,6 @@ func (c *Check) MessageNotification(operationID, sendID, recvID string, contentT
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.OperationID = operationID
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
||||
|
@ -2,22 +2,18 @@ package notification
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
//sdk "Open_IM/pkg/proto/sdkws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
//"github.com/golang/protobuf/jsonpb"
|
||||
//"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) SuperGroupNotification(operationID, sendID, recvID string) {
|
||||
func (c *Check) SuperGroupNotification(ctx context.Context, sendID, recvID string) {
|
||||
n := &NotificationMsg{
|
||||
SendID: sendID,
|
||||
RecvID: recvID,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.SuperGroupUpdateNotification,
|
||||
SessionType: constant.SingleChatType,
|
||||
OperationID: operationID,
|
||||
}
|
||||
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
|
||||
c.Notification(n)
|
||||
c.Notification(ctx, n)
|
||||
}
|
||||
|
@ -282,11 +282,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||
go func() {
|
||||
for _, userID := range userIDs {
|
||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
||||
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
s.notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs)
|
||||
s.notification.GroupCreatedNotification(ctx, group.GroupID, userIDs)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -396,7 +396,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
return nil, err
|
||||
}
|
||||
for _, userID := range req.InvitedUserIDs {
|
||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
||||
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||
}
|
||||
} else {
|
||||
opUserID := tracelog.GetOpUserID(ctx)
|
||||
@ -417,7 +417,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
||||
if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs)
|
||||
s.notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -494,7 +494,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
go func() {
|
||||
for _, userID := range req.KickedUserIDs {
|
||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
||||
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
@ -742,7 +742,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
||||
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx))
|
||||
s.notification.MemberEnterDirectlyNotification(ctx, req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx))
|
||||
return resp, nil
|
||||
}
|
||||
groupRequest := relationTb.GroupRequestModel{
|
||||
@ -769,7 +769,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx))
|
||||
s.notification.SuperGroupNotification(ctx, tracelog.GetOpUserID(ctx), tracelog.GetOpUserID(ctx))
|
||||
} else {
|
||||
_, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
@ -809,7 +809,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.GroupInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification)
|
||||
s.notification.GroupInfoSetNotification(ctx, req.GroupInfoForSet.GroupID, group.GroupName, group.Notification, group.Introduction, group.FaceURL, req.GroupInfoForSet.NeedVerification)
|
||||
if req.GroupInfoForSet.Notification != "" {
|
||||
s.GroupNotification(ctx, group.GroupID)
|
||||
}
|
||||
@ -1015,7 +1015,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.GroupMemberMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID, req.MutedSeconds)
|
||||
s.notification.GroupMemberMutedNotification(ctx, req.GroupID, req.UserID, req.MutedSeconds)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -1038,7 +1038,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.GroupMemberCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID, req.UserID)
|
||||
s.notification.GroupMemberCancelMutedNotification(ctx, req.GroupID, req.UserID)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -1050,7 +1050,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID)
|
||||
s.notification.GroupMutedNotification(ctx, req.GroupID)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID)
|
||||
s.notification.GroupCancelMutedNotification(ctx, req.GroupID)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -1139,7 +1139,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
||||
return nil, err
|
||||
}
|
||||
for _, member := range req.Members {
|
||||
s.notification.GroupMemberInfoSetNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), member.GroupID, member.UserID)
|
||||
s.notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user