mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-10 13:09:51 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
4d8e19c6bb
@ -11,4 +11,5 @@ func Access(ctx context.Context, ownerUserID string) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return tokenverify.CheckAccessV3(ctx, ownerUserID)
|
return tokenverify.CheckAccessV3(ctx, ownerUserID)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
15
internal/common/check/conversation.go
Normal file
15
internal/common/check/conversation.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package check
|
||||||
|
|
||||||
|
import (
|
||||||
|
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||||
|
pbConversation "Open_IM/pkg/proto/conversation"
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConversationChecker struct {
|
||||||
|
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (resp *pbConversation.ModifyConversationFieldResp, err error) {
|
||||||
|
return
|
||||||
|
}
|
@ -104,3 +104,15 @@ func (g *GroupChecker) GetGroupMemberInfoMap(ctx context.Context, groupID string
|
|||||||
return e.UserID
|
return e.UserID
|
||||||
}), nil
|
}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GroupChecker) GetOwnerAndAdminInfos(ctx context.Context, groupID string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||||
|
cc, err := g.getConn()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp, err := group.NewGroupClient(cc).GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{
|
||||||
|
GroupID: groupID,
|
||||||
|
RoleLevels: []int32{constant.GroupOwner, constant.GroupAdmin},
|
||||||
|
})
|
||||||
|
return resp.Members, err
|
||||||
|
}
|
||||||
|
26
internal/common/check/msg.go
Normal file
26
internal/common/check/msg.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package check
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
discoveryRegistry "Open_IM/pkg/discoveryregistry"
|
||||||
|
"Open_IM/pkg/proto/msg"
|
||||||
|
"context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MsgCheck struct {
|
||||||
|
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MsgCheck) getConn() (*grpc.ClientConn, error) {
|
||||||
|
return m.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
||||||
|
cc, err := m.getConn()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req)
|
||||||
|
return resp, err
|
||||||
|
}
|
@ -4,8 +4,10 @@ import (
|
|||||||
"Open_IM/internal/common/check"
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/tracelog"
|
||||||
"Open_IM/pkg/proto/msg"
|
"Open_IM/pkg/proto/msg"
|
||||||
"Open_IM/pkg/proto/sdkws"
|
"Open_IM/pkg/proto/sdkws"
|
||||||
|
utils2 "Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
utils "github.com/OpenIMSDK/open_utils"
|
utils "github.com/OpenIMSDK/open_utils"
|
||||||
)
|
)
|
||||||
@ -13,6 +15,7 @@ import (
|
|||||||
type Check struct {
|
type Check struct {
|
||||||
user *check.UserCheck
|
user *check.UserCheck
|
||||||
group *check.GroupChecker
|
group *check.GroupChecker
|
||||||
|
msg *check.MsgCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
type NotificationMsg struct {
|
type NotificationMsg struct {
|
||||||
@ -22,33 +25,37 @@ type NotificationMsg struct {
|
|||||||
MsgFrom int32
|
MsgFrom int32
|
||||||
ContentType int32
|
ContentType int32
|
||||||
SessionType int32
|
SessionType int32
|
||||||
OperationID string
|
|
||||||
SenderNickname string
|
SenderNickname string
|
||||||
SenderFaceURL string
|
SenderFaceURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) Notification(n *NotificationMsg) {
|
func (c *Check) Notification(ctx context.Context, notificationMsg *NotificationMsg) {
|
||||||
|
var err error
|
||||||
|
defer func() {
|
||||||
|
tracelog.SetCtxDebug(ctx, utils2.GetFuncName(1), err, "notificationMsg", notificationMsg)
|
||||||
|
}()
|
||||||
|
|
||||||
var req msg.SendMsgReq
|
var req msg.SendMsgReq
|
||||||
var msg sdkws.MsgData
|
var msg sdkws.MsgData
|
||||||
var offlineInfo sdkws.OfflinePushInfo
|
var offlineInfo sdkws.OfflinePushInfo
|
||||||
var title, desc, ex string
|
var title, desc, ex string
|
||||||
var pushSwitch, unReadCount bool
|
var pushSwitch, unReadCount bool
|
||||||
var reliabilityLevel int
|
var reliabilityLevel int
|
||||||
msg.SendID = n.SendID
|
msg.SendID = notificationMsg.SendID
|
||||||
msg.RecvID = n.RecvID
|
msg.RecvID = notificationMsg.RecvID
|
||||||
msg.Content = n.Content
|
msg.Content = notificationMsg.Content
|
||||||
msg.MsgFrom = n.MsgFrom
|
msg.MsgFrom = notificationMsg.MsgFrom
|
||||||
msg.ContentType = n.ContentType
|
msg.ContentType = notificationMsg.ContentType
|
||||||
msg.SessionType = n.SessionType
|
msg.SessionType = notificationMsg.SessionType
|
||||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||||
msg.ClientMsgID = utils.GetMsgID(n.SendID)
|
msg.ClientMsgID = utils.GetMsgID(notificationMsg.SendID)
|
||||||
msg.Options = make(map[string]bool, 7)
|
msg.Options = make(map[string]bool, 7)
|
||||||
msg.SenderNickname = n.SenderNickname
|
msg.SenderNickname = notificationMsg.SenderNickname
|
||||||
msg.SenderFaceURL = n.SenderFaceURL
|
msg.SenderFaceURL = notificationMsg.SenderFaceURL
|
||||||
switch n.SessionType {
|
switch notificationMsg.SessionType {
|
||||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
msg.RecvID = ""
|
msg.RecvID = ""
|
||||||
msg.GroupID = n.RecvID
|
msg.GroupID = notificationMsg.RecvID
|
||||||
}
|
}
|
||||||
offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount
|
offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount
|
||||||
offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound
|
offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound
|
||||||
@ -281,9 +288,5 @@ func (c *Check) Notification(n *NotificationMsg) {
|
|||||||
msg.OfflinePushInfo = &offlineInfo
|
msg.OfflinePushInfo = &offlineInfo
|
||||||
req.MsgData = &msg
|
req.MsgData = &msg
|
||||||
|
|
||||||
_, err := sendMsg(context.Background(), &req)
|
_, err = c.msg.SendMsg(ctx, &req)
|
||||||
}
|
|
||||||
|
|
||||||
func sendMsg(ctx context.Context, req *msg.SendMsgReq) (msg.SendMsgResp, error) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,21 +3,16 @@ package notification
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/common/tracelog"
|
|
||||||
sdkws "Open_IM/pkg/proto/sdkws"
|
sdkws "Open_IM/pkg/proto/sdkws"
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"github.com/golang/protobuf/jsonpb"
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Check) SetConversationNotification(operationID, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) {
|
func (c *Check) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message, tips sdkws.TipsComm) {
|
||||||
log.NewInfo(operationID, "args: ", sendID, recvID, contentType, m.String(), tips.String())
|
|
||||||
var err error
|
var err error
|
||||||
tips.Detail, err = proto.Marshal(m)
|
tips.Detail, err = proto.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, "Marshal failed ", err.Error(), m.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
marshaler := jsonpb.Marshaler{
|
marshaler := jsonpb.Marshaler{
|
||||||
@ -32,13 +27,11 @@ func (c *Check) SetConversationNotification(operationID, sendID, recvID string,
|
|||||||
n.ContentType = int32(contentType)
|
n.ContentType = int32(contentType)
|
||||||
n.SessionType = constant.SingleChatType
|
n.SessionType = constant.SingleChatType
|
||||||
n.MsgFrom = constant.SysMsgType
|
n.MsgFrom = constant.SysMsgType
|
||||||
n.OperationID = operationID
|
|
||||||
n.Content, err = proto.Marshal(&tips)
|
n.Content, err = proto.Marshal(&tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Notification(&n)
|
c.Notification(ctx, &n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPrivate调用
|
// SetPrivate调用
|
||||||
@ -57,7 +50,7 @@ func (c *Check) ConversationSetPrivateNotification(ctx context.Context, sendID,
|
|||||||
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
|
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
|
||||||
}
|
}
|
||||||
tips.DefaultTips = tipsMsg
|
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
|
var tips sdkws.TipsComm
|
||||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
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{
|
ConversationChangedTips := &sdkws.ConversationUpdateTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
@ -81,5 +74,5 @@ func (c *Check) ConversationUnreadChangeNotification(context context.Context, us
|
|||||||
}
|
}
|
||||||
var tips sdkws.TipsComm
|
var tips sdkws.TipsComm
|
||||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
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/internal/common/check"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/common/tracelog"
|
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"Open_IM/pkg/proto/sdkws"
|
"Open_IM/pkg/proto/sdkws"
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"github.com/golang/protobuf/jsonpb"
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getFromToUserNickname(userCheck *check.UserCheck, fromUserID, toUserID string) (string, string, error) {
|
func (c *Check) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
||||||
users, err := userCheck.GetUsersInfoMap(context.Background(), []string{fromUserID, toUserID}, true)
|
users, err := c.user.GetUsersInfoMap(ctx, []string{fromUserID, toUserID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", nil
|
return "", "", nil
|
||||||
}
|
}
|
||||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func friendNotification(operationID, fromUserID, toUserID string, contentType int32, m proto.Message) {
|
func (c *Check) friendNotification(ctx context.Context, fromUserID, toUserID string, contentType int32, m proto.Message) {
|
||||||
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType)
|
|
||||||
var err error
|
var err error
|
||||||
var tips sdkws.TipsComm
|
var tips sdkws.TipsComm
|
||||||
tips.Detail, err = proto.Marshal(m)
|
tips.Detail, err = proto.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +35,8 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
|||||||
|
|
||||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||||
|
|
||||||
fromUserNickname, toUserNickname, err := getFromToUserNickname(fromUserID, toUserID)
|
fromUserNickname, toUserNickname, err := c.getFromToUserNickname(ctx, fromUserID, toUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "getFromToUserNickname failed ", err.Error(), fromUserID, toUserID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cn := config.Config.Notification
|
cn := config.Config.Notification
|
||||||
@ -68,7 +62,6 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
|||||||
case constant.FriendInfoUpdatedNotification:
|
case constant.FriendInfoUpdatedNotification:
|
||||||
tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname
|
tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname
|
||||||
default:
|
default:
|
||||||
log.Error(operationID, "contentType failed ", contentType)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,20 +71,18 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
|||||||
n.ContentType = contentType
|
n.ContentType = contentType
|
||||||
n.SessionType = constant.SingleChatType
|
n.SessionType = constant.SingleChatType
|
||||||
n.MsgFrom = constant.SysMsgType
|
n.MsgFrom = constant.SysMsgType
|
||||||
n.OperationID = operationID
|
|
||||||
n.Content, err = proto.Marshal(&tips)
|
n.Content, err = proto.Marshal(&tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Notification(&n)
|
c.Notification(ctx, &n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) {
|
func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) {
|
||||||
FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}}
|
FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID
|
FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID
|
||||||
FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID
|
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) {
|
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.FromUserID = req.FromUserID
|
||||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
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) {
|
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.FromUserID = req.FromUserID
|
||||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
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) {
|
func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) {
|
||||||
friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -126,44 +117,38 @@ func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUser
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
friendAddedTips.Friend = friend
|
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) {
|
func (c *Check) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) {
|
||||||
friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||||
friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID
|
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) {
|
func (c *Check) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) {
|
||||||
friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
||||||
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
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) {
|
func (c *Check) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) {
|
||||||
blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID
|
blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||||
blackAddedTips.FromToUserID.ToUserID = req.BlackUserID
|
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) {
|
func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||||
blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||||
blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
|
func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
|
||||||
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
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"
|
"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) {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -28,12 +29,12 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G
|
|||||||
groupMemberInfo.FaceURL = user[0].FaceURL
|
groupMemberInfo.FaceURL = user[0].FaceURL
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
u, err := c.group.GetGroupMemberInfo(context.Background(), groupID, opUserID)
|
u, err := c.group.GetGroupMemberInfo(ctx, groupID, opUserID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*groupMemberInfo = *u
|
*groupMemberInfo = *u
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
user, err := c.user.GetUsersInfos(context.Background(), []string{opUserID}, true)
|
user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -46,8 +47,8 @@ func (c *Check) setOpUserInfo(opUserID, groupID string, groupMemberInfo *sdkws.G
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error {
|
func (c *Check) setGroupInfo(ctx context.Context, groupID string, groupInfo *sdkws.GroupInfo) error {
|
||||||
group, err := c.group.GetGroupInfos(context.Background(), []string{groupID}, true)
|
group, err := c.group.GetGroupInfos(ctx, []string{groupID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -55,13 +56,13 @@ func (c *Check) setGroupInfo(groupID string, groupInfo *sdkws.GroupInfo) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
func (c *Check) setGroupMemberInfo(ctx context.Context, groupID, userID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||||
groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, userID)
|
groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, userID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*groupMemberInfo = *groupMember
|
*groupMemberInfo = *groupMember
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
user, err := c.user.GetUsersInfos(context.Background(), []string{userID}, true)
|
user, err := c.user.GetUsersInfos(ctx, []string{userID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -73,12 +74,12 @@ func (c *Check) setGroupMemberInfo(groupID, userID string, groupMemberInfo *sdkw
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
func (c *Check) setGroupOwnerInfo(ctx context.Context, groupID string, groupMemberInfo *sdkws.GroupMemberFullInfo) error {
|
||||||
group, err := c.group.GetGroupInfo(context.Background(), groupID)
|
group, err := c.group.GetGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
groupMember, err := c.group.GetGroupMemberInfo(context.Background(), groupID, group.OwnerUserID)
|
groupMember, err := c.group.GetGroupMemberInfo(ctx, groupID, group.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -86,8 +87,8 @@ func (c *Check) setGroupOwnerInfo(groupID string, groupMemberInfo *sdkws.GroupMe
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUserInfo) error {
|
func (c *Check) setPublicUserInfo(ctx context.Context, userID string, publicUserInfo *sdkws.PublicUserInfo) error {
|
||||||
user, err := c.user.GetPublicUserInfos(context.Background(), []string{userID}, true)
|
user, err := c.user.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -95,13 +96,11 @@ func (c *Check) setPublicUserInfo(userID string, publicUserInfo *sdkws.PublicUse
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, groupID, recvUserID, operationID string) {
|
func (c *Check) groupNotification(ctx context.Context, contentType int32, m proto.Message, sendID, groupID, recvUserID string) {
|
||||||
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, sendID, groupID, recvUserID)
|
|
||||||
var err error
|
var err error
|
||||||
var tips sdkws.TipsComm
|
var tips sdkws.TipsComm
|
||||||
tips.Detail, err = proto.Marshal(m)
|
tips.Detail, err = proto.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
marshaler := jsonpb.Marshaler{
|
marshaler := jsonpb.Marshaler{
|
||||||
@ -113,14 +112,14 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
|||||||
var nickname, toNickname string
|
var nickname, toNickname string
|
||||||
if sendID != "" {
|
if sendID != "" {
|
||||||
|
|
||||||
from, err := c.user.GetUsersInfos(context.Background(), []string{sendID}, true)
|
from, err := c.user.GetUsersInfos(ctx, []string{sendID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nickname = from[0].Nickname
|
nickname = from[0].Nickname
|
||||||
}
|
}
|
||||||
if recvUserID != "" {
|
if recvUserID != "" {
|
||||||
to, err := c.user.GetUsersInfos(context.Background(), []string{recvUserID}, true)
|
to, err := c.user.GetUsersInfos(ctx, []string{recvUserID}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -166,7 +165,6 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
|||||||
case constant.GroupMemberSetToOrdinaryUserNotification:
|
case constant.GroupMemberSetToOrdinaryUserNotification:
|
||||||
tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips
|
tips.DefaultTips = toNickname + "" + cn.GroupMemberSetToOrdinary.DefaultTips.Tips
|
||||||
default:
|
default:
|
||||||
log.Error(operationID, "contentType failed ", contentType)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +173,7 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
|||||||
if groupID != "" {
|
if groupID != "" {
|
||||||
n.RecvID = groupID
|
n.RecvID = groupID
|
||||||
|
|
||||||
group, err := c.group.GetGroupInfo(context.Background(), groupID)
|
group, err := c.group.GetGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -190,37 +188,31 @@ func (c *Check) groupNotification(contentType int32, m proto.Message, sendID, gr
|
|||||||
n.SessionType = constant.SingleChatType
|
n.SessionType = constant.SingleChatType
|
||||||
}
|
}
|
||||||
n.ContentType = contentType
|
n.ContentType = contentType
|
||||||
n.OperationID = operationID
|
|
||||||
n.Content, err = proto.Marshal(&tips)
|
n.Content, err = proto.Marshal(&tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
|
||||||
return
|
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{},
|
GroupCreatedTips := sdkws.GroupCreatedTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}}
|
OpUser: &sdkws.GroupMemberFullInfo{}, GroupOwnerUser: &sdkws.GroupMemberFullInfo{}}
|
||||||
if err := c.setOpUserInfo(opUserID, groupID, GroupCreatedTips.OpUser); err != nil {
|
if err := c.setOpUserInfo(ctx, groupID, GroupCreatedTips.OpUser); err != nil {
|
||||||
log.NewError(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID, GroupCreatedTips.OpUser)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := c.setGroupInfo(groupID, GroupCreatedTips.Group)
|
err := c.setGroupInfo(ctx, groupID, GroupCreatedTips.Group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "setGroupInfo failed ", groupID, GroupCreatedTips.Group)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.setGroupOwnerInfo(groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
|
if err := c.setGroupOwnerInfo(ctx, groupID, GroupCreatedTips.GroupOwnerUser); err != nil {
|
||||||
log.Error(operationID, "setGroupOwnerInfo failed", err.Error(), groupID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range initMemberList {
|
for _, v := range initMemberList {
|
||||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||||
if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil {
|
||||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, v)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
GroupCreatedTips.MemberList = append(GroupCreatedTips.MemberList, &groupMemberInfo)
|
||||||
@ -228,7 +220,8 @@ func (c *Check) GroupCreatedNotification(operationID, opUserID, groupID string,
|
|||||||
break
|
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 := ""
|
// notification := ""
|
||||||
// introduction := ""
|
// introduction := ""
|
||||||
// faceURL := ""
|
// 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{}}
|
GroupInfoChangedTips := sdkws.GroupInfoSetTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||||
if err := c.setGroupInfo(groupID, GroupInfoChangedTips.Group); err != nil {
|
if err := c.setGroupInfo(ctx, groupID, GroupInfoChangedTips.Group); err != nil {
|
||||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GroupInfoChangedTips.Group.GroupName = groupName
|
GroupInfoChangedTips.Group.GroupName = groupName
|
||||||
@ -251,116 +243,102 @@ func (c *Check) GroupInfoSetNotification(operationID, opUserID, groupID string,
|
|||||||
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
|
GroupInfoChangedTips.Group.NeedVerification = needVerification.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.setOpUserInfo(opUserID, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
if err := c.setOpUserInfo(ctx, groupID, GroupInfoChangedTips.OpUser); err != nil {
|
||||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
|
||||||
return
|
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{},
|
tips := sdkws.GroupMutedTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}}
|
OpUser: &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
|
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
|
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{},
|
tips := sdkws.GroupCancelMutedTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}}
|
OpUser: &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
|
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
|
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{},
|
tips := sdkws.GroupMemberMutedTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}}
|
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}}
|
||||||
tips.MutedSeconds = mutedSeconds
|
tips.MutedSeconds = mutedSeconds
|
||||||
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
|
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
|
return
|
||||||
}
|
}
|
||||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
|
||||||
return
|
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{},
|
tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
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
|
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 {
|
if notificationType != constant.GroupMemberSetToAdminNotification && notificationType != constant.GroupMemberSetToOrdinaryUserNotification {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType)
|
log.NewError(operationID, utils.GetSelfFuncName(), "invalid notificationType: ", notificationType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{},
|
tips := sdkws.GroupMemberInfoSetTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}, ChangedUser: &sdkws.GroupMemberFullInfo{}}
|
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)
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
||||||
return
|
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)
|
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
||||||
return
|
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)
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
||||||
return
|
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{},
|
tips := sdkws.GroupMemberCancelMutedTips{Group: &sdkws.GroupInfo{},
|
||||||
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &sdkws.GroupMemberFullInfo{}}
|
OpUser: &sdkws.GroupMemberFullInfo{}, MutedUser: &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
|
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
|
return
|
||||||
}
|
}
|
||||||
if err := c.setGroupMemberInfo(groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
if err := c.setGroupMemberInfo(ctx, groupID, groupMemberUserID, tips.MutedUser); err != nil {
|
||||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, groupMemberUserID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.groupNotification(constant.GroupMemberCancelMutedNotification, &tips, opUserID, groupID, "", operationID)
|
c.groupNotification(ctx, constant.GroupMemberCancelMutedNotification, &tips, tracelog.GetOpUserID(ctx), groupID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// message ReceiveJoinApplicationTips{
|
// message ReceiveJoinApplicationTips{
|
||||||
@ -376,38 +354,35 @@ func (c *Check) GroupMemberCancelMutedNotification(operationID, opUserID, groupI
|
|||||||
// 申请进群后调用
|
// 申请进群后调用
|
||||||
func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) {
|
func (c *Check) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) {
|
||||||
JoinGroupApplicationTips := sdkws.JoinGroupApplicationTips{Group: &sdkws.GroupInfo{}, Applicant: &sdkws.PublicUserInfo{}}
|
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 {
|
if err != nil {
|
||||||
|
|
||||||
return
|
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
|
return
|
||||||
}
|
}
|
||||||
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
JoinGroupApplicationTips.ReqMsg = req.ReqMessage
|
||||||
|
managerList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||||
managerList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range managerList {
|
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) {
|
func (c *Check) MemberQuitNotification(ctx context.Context, req *pbGroup.QuitGroupReq) {
|
||||||
MemberQuitTips := sdkws.MemberQuitTips{Group: &sdkws.GroupInfo{}, QuitUser: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
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{
|
// 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) {
|
func (c *Check) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||||
GroupApplicationAcceptedTips := sdkws.GroupApplicationAcceptedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
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
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.groupNotification(constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx))
|
c.groupNotification(ctx, constant.GroupApplicationAcceptedNotification, &GroupApplicationAcceptedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID)
|
||||||
adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.OperationID, "GetOwnerManagerByGroupID failed", req.GroupID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range adminList {
|
for _, v := range adminList {
|
||||||
if v.UserID == req.OpUserID {
|
if v.UserID == tracelog.GetOpUserID(ctx) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GroupApplicationAcceptedTips.ReceiverAs = 1
|
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) {
|
func (c *Check) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||||
GroupApplicationRejectedTips := sdkws.GroupApplicationRejectedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, HandleMsg: req.HandledMsg}
|
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
|
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
|
return
|
||||||
}
|
}
|
||||||
c.groupNotification(constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID, tracelog.GetOperationID(ctx))
|
c.groupNotification(ctx, constant.GroupApplicationRejectedNotification, &GroupApplicationRejectedTips, tracelog.GetOpUserID(ctx), "", req.FromUserID)
|
||||||
adminList, err := imdb.GetOwnerManagerByGroupID(req.GroupID)
|
adminList, err := c.group.GetOwnerAndAdminInfos(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range adminList {
|
for _, v := range adminList {
|
||||||
if v.UserID == req.OpUserID {
|
if v.UserID == tracelog.GetOpUserID(ctx) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GroupApplicationRejectedTips.ReceiverAs = 1
|
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) {
|
func (c *Check) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) {
|
||||||
GroupOwnerTransferredTips := sdkws.GroupOwnerTransferredTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}, NewGroupOwner: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
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
|
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) {
|
func (c *Check) GroupDismissedNotification(ctx context.Context, req *pbGroup.DismissGroupReq) {
|
||||||
tips := sdkws.GroupDismissedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
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{
|
// 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) {
|
func (c *Check) MemberKickedNotification(ctx context.Context, req *pbGroup.KickGroupMemberReq, kickedUserIDList []string) {
|
||||||
MemberKickedTips := sdkws.MemberKickedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
return
|
||||||
}
|
}
|
||||||
for _, v := range kickedUserIDList {
|
for _, v := range kickedUserIDList {
|
||||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
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
|
continue
|
||||||
}
|
}
|
||||||
MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
|
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 {
|
//for _, v := range kickedUserIDList {
|
||||||
// groupNotification(constant.MemberKickedNotification, &MemberKickedTips, req.OpUserID, "", v, req.OperationID)
|
// 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{}}
|
MemberInvitedTips := sdkws.MemberInvitedTips{Group: &sdkws.GroupInfo{}, OpUser: &sdkws.GroupMemberFullInfo{}}
|
||||||
if err := c.setGroupInfo(groupID, MemberInvitedTips.Group); err != nil {
|
if err := c.setGroupInfo(ctx, groupID, MemberInvitedTips.Group); err != nil {
|
||||||
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := c.setOpUserInfo(opUserID, groupID, MemberInvitedTips.OpUser); err != nil {
|
if err := c.setOpUserInfo(ctx, groupID, MemberInvitedTips.OpUser); err != nil {
|
||||||
log.Error(operationID, "setOpUserInfo failed ", err.Error(), opUserID, groupID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range invitedUserIDList {
|
for _, v := range invitedUserIDList {
|
||||||
var groupMemberInfo sdkws.GroupMemberFullInfo
|
var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||||
if err := c.setGroupMemberInfo(groupID, v, &groupMemberInfo); err != nil {
|
if err := c.setGroupMemberInfo(ctx, groupID, v, &groupMemberInfo); err != nil {
|
||||||
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
MemberInvitedTips.InvitedUserList = append(MemberInvitedTips.InvitedUserList, &groupMemberInfo)
|
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) {
|
func (c *Check) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) {
|
||||||
MemberEnterTips := sdkws.MemberEnterTips{Group: &sdkws.GroupInfo{}, EntrantUser: &sdkws.GroupMemberFullInfo{}}
|
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
|
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
|
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{}}
|
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)
|
log.Error(operationID, "setGroupInfo failed ", err.Error(), groupID, MemberEnterTips.Group)
|
||||||
return
|
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)
|
log.Error(operationID, "setGroupMemberInfo failed ", err.Error(), groupID, entrantUserID, MemberEnterTips.EntrantUser)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.groupNotification(constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "", operationID)
|
c.groupNotification(ctx, constant.MemberEnterNotification, &MemberEnterTips, entrantUserID, groupID, "")
|
||||||
}
|
}
|
||||||
|
@ -2,25 +2,22 @@ package notification
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/proto/sdkws"
|
"Open_IM/pkg/proto/sdkws"
|
||||||
"Open_IM/pkg/utils"
|
"context"
|
||||||
"github.com/golang/protobuf/jsonpb"
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"github.com/golang/protobuf/proto"
|
"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}
|
DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, SeqList: seqList}
|
||||||
c.MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
|
c.MessageNotification(ctx, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Check) MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) {
|
func (c *Check) MessageNotification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message) {
|
||||||
log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType)
|
|
||||||
var err error
|
var err error
|
||||||
var tips sdkws.TipsComm
|
var tips sdkws.TipsComm
|
||||||
tips.Detail, err = proto.Marshal(m)
|
tips.Detail, err = proto.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +34,9 @@ func (c *Check) MessageNotification(operationID, sendID, recvID string, contentT
|
|||||||
n.ContentType = contentType
|
n.ContentType = contentType
|
||||||
n.SessionType = constant.SingleChatType
|
n.SessionType = constant.SingleChatType
|
||||||
n.MsgFrom = constant.SysMsgType
|
n.MsgFrom = constant.SysMsgType
|
||||||
n.OperationID = operationID
|
|
||||||
n.Content, err = proto.Marshal(&tips)
|
n.Content, err = proto.Marshal(&tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Notification(&n)
|
c.Notification(ctx, &n)
|
||||||
}
|
}
|
||||||
|
@ -2,22 +2,18 @@ package notification
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"context"
|
||||||
//sdk "Open_IM/pkg/proto/sdkws"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
//"github.com/golang/protobuf/jsonpb"
|
//"github.com/golang/protobuf/jsonpb"
|
||||||
//"github.com/golang/protobuf/proto"
|
//"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{
|
n := &NotificationMsg{
|
||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
RecvID: recvID,
|
RecvID: recvID,
|
||||||
MsgFrom: constant.SysMsgType,
|
MsgFrom: constant.SysMsgType,
|
||||||
ContentType: constant.SuperGroupUpdateNotification,
|
ContentType: constant.SuperGroupUpdateNotification,
|
||||||
SessionType: constant.SingleChatType,
|
SessionType: constant.SingleChatType,
|
||||||
OperationID: operationID,
|
|
||||||
}
|
}
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
|
c.Notification(ctx, n)
|
||||||
c.Notification(n)
|
|
||||||
}
|
}
|
||||||
|
13
internal/common/notification/user.go
Normal file
13
internal/common/notification/user.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package notification
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/proto/sdkws"
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// send to myself
|
||||||
|
func (c *Check) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) {
|
||||||
|
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||||
|
c.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||||
|
}
|
@ -3,7 +3,7 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"Open_IM/internal/common/check"
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/internal/common/convert"
|
"Open_IM/internal/common/convert"
|
||||||
chat "Open_IM/internal/common/notification"
|
"Open_IM/internal/common/notification"
|
||||||
"Open_IM/internal/common/rpcserver"
|
"Open_IM/internal/common/rpcserver"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
@ -26,6 +26,8 @@ type friendServer struct {
|
|||||||
*rpcserver.RpcServer
|
*rpcserver.RpcServer
|
||||||
controller.FriendInterface
|
controller.FriendInterface
|
||||||
controller.BlackInterface
|
controller.BlackInterface
|
||||||
|
notification *notification.Check
|
||||||
|
userCheck *check.UserCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFriendServer(port int) *friendServer {
|
func NewFriendServer(port int) *friendServer {
|
||||||
@ -105,7 +107,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply
|
|||||||
if req.ToUserID == req.FromUserID {
|
if req.ToUserID == req.FromUserID {
|
||||||
return nil, constant.ErrCanNotAddYourself.Wrap()
|
return nil, constant.ErrCanNotAddYourself.Wrap()
|
||||||
}
|
}
|
||||||
if _, err := check.GetUsersInfo(ctx, req.ToUserID, req.FromUserID); err != nil {
|
if _, err := s.userCheck.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}, true); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
||||||
@ -118,7 +120,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.Apply
|
|||||||
if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
|
if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.FriendApplicationAddNotification(ctx, req)
|
s.notification.FriendApplicationAddNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +130,7 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFr
|
|||||||
if err := tokenverify.CheckAdmin(ctx); err != nil {
|
if err := tokenverify.CheckAdmin(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, err := check.NewUserCheck().GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil {
|
if _, err := s.userCheck.GetUsersInfos(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...), true); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.FriendApplicationAgreedNotification(ctx, req)
|
s.notification.FriendApplicationAgreedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
if req.HandleResult == constant.FriendResponseRefuse {
|
if req.HandleResult == constant.FriendResponseRefuse {
|
||||||
@ -165,7 +167,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.FriendApplicationRefusedNotification(ctx, req)
|
s.notification.FriendApplicationRefusedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
return nil, constant.ErrArgs.Wrap("req.HandleResult != -1/1")
|
return nil, constant.ErrArgs.Wrap("req.HandleResult != -1/1")
|
||||||
@ -184,7 +186,7 @@ func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFri
|
|||||||
if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil {
|
if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.FriendDeletedNotification(ctx, req)
|
s.notification.FriendDeletedNotification(ctx, req)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +203,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri
|
|||||||
if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
|
if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
|
s.notification.FriendRemarkSetNotification(ctx, req.OwnerUserID, req.FriendUserID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,11 +183,11 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
if req.GroupInfo.GroupType == constant.SuperGroup {
|
if req.GroupInfo.GroupType == constant.SuperGroup {
|
||||||
go func() {
|
go func() {
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
s.notification.GroupCreatedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), group.GroupID, userIDs)
|
s.notification.GroupCreatedNotification(ctx, group.GroupID, userIDs)
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, userID := range req.InvitedUserIDs {
|
for _, userID := range req.InvitedUserIDs {
|
||||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
opUserID := tracelog.GetOpUserID(ctx)
|
opUserID := tracelog.GetOpUserID(ctx)
|
||||||
@ -318,7 +318,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil {
|
if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil {
|
||||||
return nil, err
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -395,7 +395,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for _, userID := range req.KickedUserIDs {
|
for _, userID := range req.KickedUserIDs {
|
||||||
s.notification.SuperGroupNotification(tracelog.GetOperationID(ctx), userID, userID)
|
s.notification.SuperGroupNotification(ctx, userID, userID)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
@ -643,7 +643,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|||||||
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
if err := s.GroupInterface.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
|
||||||
return nil, err
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupRequest := relationTb.GroupRequestModel{
|
groupRequest := relationTb.GroupRequestModel{
|
||||||
@ -670,7 +670,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 {
|
if err := s.GroupInterface.DeleteSuperGroupMember(ctx, req.GroupID, []string{tracelog.GetOpUserID(ctx)}); err != nil {
|
||||||
return nil, err
|
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 {
|
} else {
|
||||||
_, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
_, err := s.GroupInterface.TakeGroupMember(ctx, req.GroupID, tracelog.GetOpUserID(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -710,7 +710,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 != "" {
|
if req.GroupInfoForSet.Notification != "" {
|
||||||
s.GroupNotification(ctx, group.GroupID)
|
s.GroupNotification(ctx, group.GroupID)
|
||||||
}
|
}
|
||||||
@ -916,7 +916,7 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
|||||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||||
return nil, err
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,7 +939,7 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
|||||||
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
if err := s.GroupInterface.UpdateGroupMember(ctx, member.GroupID, member.UserID, data); err != nil {
|
||||||
return nil, err
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
|||||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil {
|
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupStatusMuted)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.notification.GroupMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID)
|
s.notification.GroupMutedNotification(ctx, req.GroupID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,7 +963,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|||||||
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil {
|
if err := s.GroupInterface.UpdateGroup(ctx, req.GroupID, UpdateGroupStatusMap(constant.GroupOk)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.notification.GroupCancelMutedNotification(tracelog.GetOperationID(ctx), tracelog.GetOpUserID(ctx), req.GroupID)
|
s.notification.GroupCancelMutedNotification(ctx, req.GroupID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1040,7 +1040,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, member := range req.Members {
|
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
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func copyCallbackCommonReqStruct(msg *pbChat.SendMsgReq) cbapi.CommonCallbackReq
|
|||||||
return req
|
return req
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) error {
|
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (err error) {
|
||||||
callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID}
|
callbackResp := cbapi.CommonCallbackResp{OperationID: msg.OperationID}
|
||||||
if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable {
|
if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable {
|
||||||
return callbackResp
|
return callbackResp
|
||||||
|
@ -116,13 +116,12 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (
|
|||||||
var memberKickedTips sdkws.MemberKickedTips
|
var memberKickedTips sdkws.MemberKickedTips
|
||||||
err := proto.Unmarshal(req.MsgData.Content, &tips)
|
err := proto.Unmarshal(req.MsgData.Content, &tips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
err = proto.Unmarshal(tips.Detail, &memberKickedTips)
|
err = proto.Unmarshal(tips.Detail, &memberKickedTips)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range memberKickedTips.KickedUserList {
|
for _, v := range memberKickedTips.KickedUserList {
|
||||||
addUidList = append(addUidList, v.UserID)
|
addUidList = append(addUidList, v.UserID)
|
||||||
}
|
}
|
||||||
@ -204,7 +203,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (
|
|||||||
conversation.GroupAtType = constant.AtMe
|
conversation.GroupAtType = constant.AtMe
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := m.ModifyConversationField(context.Background(), &conversationReq)
|
_, err := m.Conversation.ModifyConversationField(ctx, &conversationReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -212,7 +211,7 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (
|
|||||||
if tag {
|
if tag {
|
||||||
conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList)
|
conversationReq.UserIDList = utils.DifferenceString(atUserID, memberUserIDList)
|
||||||
conversation.GroupAtType = constant.AtAll
|
conversation.GroupAtType = constant.AtAll
|
||||||
_, err := m.ModifyConversationField(context.Background(), &conversationReq)
|
_, err := m.Conversation.ModifyConversationField(ctx, &conversationReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -228,10 +227,6 @@ func (m *msgServer) sendMsgGroupChat(ctx context.Context, req *msg.SendMsgReq) (
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) {
|
func (m *msgServer) SendMsg(ctx context.Context, req *msg.SendMsgReq) (resp *msg.SendMsgResp, error error) {
|
||||||
resp = &msg.SendMsgResp{}
|
resp = &msg.SendMsgResp{}
|
||||||
flag := isMessageHasReadEnabled(req.MsgData)
|
flag := isMessageHasReadEnabled(req.MsgData)
|
||||||
@ -305,60 +300,5 @@ func (m *msgServer) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMes
|
|||||||
MsgDataList: msgs,
|
MsgDataList: msgs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(req.UserID, req.SeqList, req.OperationID)
|
|
||||||
//if err != nil {
|
|
||||||
// if err != go_redis.Nil {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList))
|
|
||||||
// log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList)
|
|
||||||
// } else {
|
|
||||||
// log.Debug(req.OperationID, "get message from redis is nil", failedSeqList)
|
|
||||||
// }
|
|
||||||
// msgList, err1 := commonDB.DB.GetMsgBySeqListMongo2(req.UserID, failedSeqList, req.OperationID)
|
|
||||||
// if err1 != nil {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
|
||||||
// log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error())
|
|
||||||
// resp.ErrCode = 201
|
|
||||||
// resp.ErrMsg = err1.Error()
|
|
||||||
// return resp, nil
|
|
||||||
// } else {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList))
|
|
||||||
// redisMsgList = append(redisMsgList, msgList...)
|
|
||||||
// resp.List = redisMsgList
|
|
||||||
// }
|
|
||||||
//} else {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList))
|
|
||||||
// resp.List = redisMsgList
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//for k, v := range req.GroupSeqList {
|
|
||||||
// x := new(sdkws.MsgDataList)
|
|
||||||
// redisMsgList, failedSeqList, err := commonDB.DB.GetMessageListBySeq(k, v.SeqList, req.OperationID)
|
|
||||||
// if err != nil {
|
|
||||||
// if err != go_redis.Nil {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromRedisFailedCounter, len(failedSeqList))
|
|
||||||
// log.Error(req.OperationID, "get message from redis exception", err.Error(), failedSeqList)
|
|
||||||
// } else {
|
|
||||||
// log.Debug(req.OperationID, "get message from redis is nil", failedSeqList)
|
|
||||||
// }
|
|
||||||
// msgList, err1 := commonDB.DB.GetSuperGroupMsgBySeqListMongo(k, failedSeqList, req.OperationID)
|
|
||||||
// if err1 != nil {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromMongoFailedCounter, len(failedSeqList))
|
|
||||||
// log.Error(req.OperationID, "PullMessageBySeqList data error", req.String(), err1.Error())
|
|
||||||
// resp.ErrCode = 201
|
|
||||||
// resp.ErrMsg = err1.Error()
|
|
||||||
// return resp, nil
|
|
||||||
// } else {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromMongoSuccessCounter, len(msgList))
|
|
||||||
// redisMsgList = append(redisMsgList, msgList...)
|
|
||||||
// x.MsgDataList = redisMsgList
|
|
||||||
// m[k] = x
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// promePkg.PromeAdd(promePkg.MsgPullFromRedisSuccessCounter, len(redisMsgList))
|
|
||||||
// x.MsgDataList = redisMsgList
|
|
||||||
// m[k] = x
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ type msgServer struct {
|
|||||||
MsgInterface controller.MsgInterface
|
MsgInterface controller.MsgInterface
|
||||||
Group *check.GroupChecker
|
Group *check.GroupChecker
|
||||||
User *check.UserCheck
|
User *check.UserCheck
|
||||||
|
Conversation *check.ConversationChecker
|
||||||
}
|
}
|
||||||
|
|
||||||
type deleteMsg struct {
|
type deleteMsg struct {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/internal/common/convert"
|
"Open_IM/internal/common/convert"
|
||||||
chat "Open_IM/internal/common/notification"
|
"Open_IM/internal/common/notification"
|
||||||
"Open_IM/internal/common/rpcserver"
|
"Open_IM/internal/common/rpcserver"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
@ -25,6 +26,8 @@ import (
|
|||||||
type userServer struct {
|
type userServer struct {
|
||||||
*rpcserver.RpcServer
|
*rpcserver.RpcServer
|
||||||
controller.UserInterface
|
controller.UserInterface
|
||||||
|
notification *notification.Check
|
||||||
|
userCheck *check.UserCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserServer(port int) *userServer {
|
func NewUserServer(port int) *userServer {
|
||||||
@ -226,11 +229,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
for _, v := range friends {
|
for _, v := range friends {
|
||||||
chat.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
|
s.notification.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v.FriendUser.UserID, tracelog.GetOpUserID(ctx))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
chat.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
|
s.notification.UserInfoUpdatedNotification(ctx, tracelog.GetOpUserID(ctx), req.UserInfo.UserID)
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
@ -246,7 +249,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se
|
|||||||
if err := s.UpdateByMap(ctx, req.UserID, m); err != nil {
|
if err := s.UpdateByMap(ctx, req.UserID, m); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chat.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID)
|
s.notification.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user