parent
c80babaef6
commit
94b5703399
@ -1,14 +0,0 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
||||
)
|
||||
|
||||
func (u *UserCheck) Access(ctx context.Context, ownerUserID string) (err error) {
|
||||
_, err = u.GetUserInfo(ctx, ownerUserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tokenverify.CheckAccessV3(ctx, ownerUserID)
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type ConversationChecker struct {
|
||||
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func NewConversationChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *ConversationChecker {
|
||||
return &ConversationChecker{zk: zk}
|
||||
}
|
||||
|
||||
func (c *ConversationChecker) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
|
||||
cc, err := c.getConn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationChecker) getConn() (*grpc.ClientConn, error) {
|
||||
return c.zk.GetConn(config.Config.RpcRegisterName.OpenImConversationName)
|
||||
}
|
||||
|
||||
func (c *ConversationChecker) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
cc, err := c.getConn()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var req conversation.GetConversationReq
|
||||
req.OwnerUserID = userID
|
||||
req.ConversationID = conversationID
|
||||
sConversation, err := conversation.NewConversationClient(cc).GetConversation(ctx, &req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return sConversation.GetConversation().RecvMsgOpt, err
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
||||
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type FriendChecker struct {
|
||||
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func NewFriendChecker(zk discoveryRegistry.SvcDiscoveryRegistry) *FriendChecker {
|
||||
return &FriendChecker{
|
||||
zk: zk,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FriendChecker) GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (resp *sdkws.FriendInfo, err error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err := friend.NewFriendClient(cc).GetDesignatedFriends(ctx, &friend.GetDesignatedFriendsReq{OwnerUserID: ownerUserID, FriendUserIDs: []string{friendUserID}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp = r.FriendsInfo[0]
|
||||
return
|
||||
}
|
||||
func (f *FriendChecker) getConn() (*grpc.ClientConn, error) {
|
||||
return f.zk.GetConn(config.Config.RpcRegisterName.OpenImFriendName)
|
||||
}
|
||||
|
||||
// possibleFriendUserID是否在userID的好友中
|
||||
func (f *FriendChecker) IsFriend(ctx context.Context, possibleFriendUserID, userID string) (bool, error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
resp, err := friend.NewFriendClient(cc).IsFriend(ctx, &friend.IsFriendReq{UserID1: userID, UserID2: possibleFriendUserID})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return resp.InUser1Friends, nil
|
||||
|
||||
}
|
||||
|
||||
func (f *FriendChecker) GetFriendIDs(ctx context.Context, ownerUserID string) (friendIDs []string, err error) {
|
||||
cc, err := f.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req := friend.GetFriendIDsReq{UserID: ownerUserID}
|
||||
resp, err := friend.NewFriendClient(cc).GetFriendIDs(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.FriendIDs, err
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type MsgCheck struct {
|
||||
zk discoveryRegistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func NewMsgCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *MsgCheck {
|
||||
return &MsgCheck{zk: zk}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (m *MsgCheck) GetMaxAndMinSeq(ctx context.Context, req *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) {
|
||||
cc, err := m.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := msg.NewMsgClient(cc).GetMaxAndMinSeq(ctx, req)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (m *MsgCheck) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||||
cc, err := m.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := msg.NewMsgClient(cc).PullMessageBySeqs(ctx, req)
|
||||
return resp, err
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package check
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
func NewUserCheck(client discoveryregistry.SvcDiscoveryRegistry) *UserCheck {
|
||||
return &UserCheck{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
type UserCheck struct {
|
||||
client discoveryregistry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (u *UserCheck) getConn() (*grpc.ClientConn, error) {
|
||||
return u.client.GetConn(config.Config.RpcRegisterName.OpenImUserName)
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetUsersInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.UserInfo, error) {
|
||||
cc, err := u.getConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := user.NewUserClient(cc).GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
|
||||
UserIDs: userIDs,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if complete {
|
||||
if ids := utils.Single(userIDs, utils.Slice(resp.UsersInfo, func(e *sdkws.UserInfo) string {
|
||||
return e.UserID
|
||||
})); len(ids) > 0 {
|
||||
return nil, errs.ErrUserIDNotFound.Wrap(strings.Join(ids, ","))
|
||||
}
|
||||
}
|
||||
return resp.UsersInfo, nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetUsersInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.UserInfo, error) {
|
||||
users, err := u.GetUsersInfos(ctx, userIDs, complete)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
|
||||
return e.UserID
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetPublicUserInfos(ctx context.Context, userIDs []string, complete bool) ([]*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetUsersInfos(ctx, userIDs, complete)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo {
|
||||
return &sdkws.PublicUserInfo{
|
||||
UserID: e.UserID,
|
||||
Nickname: e.Nickname,
|
||||
FaceURL: e.FaceURL,
|
||||
Ex: e.Ex,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return users[0], nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetPublicUserInfoMap(ctx context.Context, userIDs []string, complete bool) (map[string]*sdkws.PublicUserInfo, error) {
|
||||
users, err := u.GetPublicUserInfos(ctx, userIDs, complete)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
|
||||
return e.UserID
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (u *UserCheck) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
|
||||
cc, err := u.getConn()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
resp, err := user.NewUserClient(cc).GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||
UserID: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return resp.GlobalRecvMsgOpt, err
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package rpcclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
)
|
||||
|
||||
type ConversationClient struct {
|
||||
*MetaClient
|
||||
}
|
||||
|
||||
func NewConversationClient(zk discoveryRegistry.SvcDiscoveryRegistry) *ConversationClient {
|
||||
return &ConversationClient{NewMetaClient(zk, config.Config.RpcRegisterName.OpenImConversationName)}
|
||||
}
|
||||
|
||||
func (c *ConversationClient) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) error {
|
||||
cc, err := c.getConn()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = conversation.NewConversationClient(cc).ModifyConversationField(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *ConversationClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||
cc, err := c.getConn()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var req conversation.GetConversationReq
|
||||
req.OwnerUserID = userID
|
||||
req.ConversationID = conversationID
|
||||
conversation, err := conversation.NewConversationClient(cc).GetConversation(ctx, &req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return conversation.GetConversation().RecvMsgOpt, err
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
)
|
||||
|
||||
func UsersDB2Pb(users []*relationTb.UserModel) (result []*sdkws.UserInfo) {
|
||||
for _, user := range users {
|
||||
var userPb sdkws.UserInfo
|
||||
userPb.UserID = user.UserID
|
||||
userPb.Nickname = user.Nickname
|
||||
userPb.FaceURL = user.FaceURL
|
||||
userPb.Ex = user.Ex
|
||||
userPb.CreateTime = user.CreateTime.Unix()
|
||||
userPb.AppMangerLevel = user.AppMangerLevel
|
||||
userPb.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func UserPb2DB(user *sdkws.UserInfo) *relationTb.UserModel {
|
||||
var userDB relationTb.UserModel
|
||||
userDB.UserID = user.UserID
|
||||
userDB.Nickname = user.Nickname
|
||||
userDB.FaceURL = user.FaceURL
|
||||
userDB.Ex = user.Ex
|
||||
userDB.CreateTime = time.Unix(user.CreateTime, 0)
|
||||
userDB.AppMangerLevel = user.AppMangerLevel
|
||||
userDB.GlobalRecvMsgOpt = user.GlobalRecvMsgOpt
|
||||
return &userDB
|
||||
}
|
@ -1,299 +0,0 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/check"
|
||||
utils "github.com/OpenIMSDK/open_utils"
|
||||
)
|
||||
|
||||
type Check struct {
|
||||
user *check.UserCheck
|
||||
group *check.GroupChecker
|
||||
Msg *check.MsgCheck
|
||||
friend *check.FriendChecker
|
||||
conversation *check.ConversationChecker
|
||||
}
|
||||
|
||||
func NewCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *Check {
|
||||
return &Check{
|
||||
user: check.NewUserCheck(zk),
|
||||
group: check.NewGroupChecker(zk),
|
||||
Msg: check.NewMsgCheck(zk),
|
||||
friend: check.NewFriendChecker(zk),
|
||||
conversation: check.NewConversationChecker(zk),
|
||||
}
|
||||
}
|
||||
|
||||
type NotificationMsg struct {
|
||||
SendID string
|
||||
RecvID string
|
||||
Content []byte // sdkws.TipsComm
|
||||
MsgFrom int32
|
||||
ContentType int32
|
||||
SessionType int32
|
||||
SenderNickname string
|
||||
SenderFaceURL string
|
||||
}
|
||||
|
||||
func (c *Check) Notification(ctx context.Context, notificationMsg *NotificationMsg) error {
|
||||
var err error
|
||||
var req msg.SendMsgReq
|
||||
var msg sdkws.MsgData
|
||||
var offlineInfo sdkws.OfflinePushInfo
|
||||
var title, desc, ex string
|
||||
var pushSwitch, unReadCount bool
|
||||
var reliabilityLevel int
|
||||
msg.SendID = notificationMsg.SendID
|
||||
msg.RecvID = notificationMsg.RecvID
|
||||
msg.Content = notificationMsg.Content
|
||||
msg.MsgFrom = notificationMsg.MsgFrom
|
||||
msg.ContentType = notificationMsg.ContentType
|
||||
msg.SessionType = notificationMsg.SessionType
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = utils.GetMsgID(notificationMsg.SendID)
|
||||
msg.Options = make(map[string]bool, 7)
|
||||
msg.SenderNickname = notificationMsg.SenderNickname
|
||||
msg.SenderFaceURL = notificationMsg.SenderFaceURL
|
||||
switch notificationMsg.SessionType {
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
msg.RecvID = ""
|
||||
msg.GroupID = notificationMsg.RecvID
|
||||
}
|
||||
offlineInfo.IOSBadgeCount = config.Config.IOSPush.BadgeCount
|
||||
offlineInfo.IOSPushSound = config.Config.IOSPush.PushSound
|
||||
switch msg.ContentType {
|
||||
case constant.GroupCreatedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupCreated.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupCreated.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupCreated.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupCreated.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupCreated.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupCreated.Conversation.UnreadCount
|
||||
case constant.GroupInfoSetNotification:
|
||||
pushSwitch = config.Config.Notification.GroupInfoSet.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupInfoSet.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupInfoSet.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupInfoSet.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupInfoSet.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupInfoSet.Conversation.UnreadCount
|
||||
case constant.JoinGroupApplicationNotification:
|
||||
pushSwitch = config.Config.Notification.JoinGroupApplication.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.JoinGroupApplication.OfflinePush.Title
|
||||
desc = config.Config.Notification.JoinGroupApplication.OfflinePush.Desc
|
||||
ex = config.Config.Notification.JoinGroupApplication.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.JoinGroupApplication.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.JoinGroupApplication.Conversation.UnreadCount
|
||||
case constant.MemberQuitNotification:
|
||||
pushSwitch = config.Config.Notification.MemberQuit.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.MemberQuit.OfflinePush.Title
|
||||
desc = config.Config.Notification.MemberQuit.OfflinePush.Desc
|
||||
ex = config.Config.Notification.MemberQuit.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.MemberQuit.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.MemberQuit.Conversation.UnreadCount
|
||||
case constant.GroupApplicationAcceptedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupApplicationAccepted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupApplicationAccepted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupApplicationAccepted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupApplicationAccepted.Conversation.UnreadCount
|
||||
case constant.GroupApplicationRejectedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupApplicationRejected.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupApplicationRejected.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupApplicationRejected.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupApplicationRejected.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupApplicationRejected.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupApplicationRejected.Conversation.UnreadCount
|
||||
case constant.GroupOwnerTransferredNotification:
|
||||
pushSwitch = config.Config.Notification.GroupOwnerTransferred.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupOwnerTransferred.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupOwnerTransferred.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupOwnerTransferred.Conversation.UnreadCount
|
||||
case constant.MemberKickedNotification:
|
||||
pushSwitch = config.Config.Notification.MemberKicked.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.MemberKicked.OfflinePush.Title
|
||||
desc = config.Config.Notification.MemberKicked.OfflinePush.Desc
|
||||
ex = config.Config.Notification.MemberKicked.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.MemberKicked.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.MemberKicked.Conversation.UnreadCount
|
||||
case constant.MemberInvitedNotification:
|
||||
pushSwitch = config.Config.Notification.MemberInvited.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.MemberInvited.OfflinePush.Title
|
||||
desc = config.Config.Notification.MemberInvited.OfflinePush.Desc
|
||||
ex = config.Config.Notification.MemberInvited.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.MemberInvited.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.MemberInvited.Conversation.UnreadCount
|
||||
case constant.MemberEnterNotification:
|
||||
pushSwitch = config.Config.Notification.MemberEnter.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.MemberEnter.OfflinePush.Title
|
||||
desc = config.Config.Notification.MemberEnter.OfflinePush.Desc
|
||||
ex = config.Config.Notification.MemberEnter.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.MemberEnter.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.MemberEnter.Conversation.UnreadCount
|
||||
case constant.UserInfoUpdatedNotification:
|
||||
pushSwitch = config.Config.Notification.UserInfoUpdated.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.UserInfoUpdated.OfflinePush.Title
|
||||
desc = config.Config.Notification.UserInfoUpdated.OfflinePush.Desc
|
||||
ex = config.Config.Notification.UserInfoUpdated.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.UserInfoUpdated.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.UserInfoUpdated.Conversation.UnreadCount
|
||||
case constant.FriendApplicationNotification:
|
||||
pushSwitch = config.Config.Notification.FriendApplication.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendApplication.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendApplication.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendApplication.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendApplication.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendApplication.Conversation.UnreadCount
|
||||
case constant.FriendApplicationApprovedNotification:
|
||||
pushSwitch = config.Config.Notification.FriendApplicationApproved.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendApplicationApproved.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendApplicationApproved.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendApplicationApproved.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendApplicationApproved.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendApplicationApproved.Conversation.UnreadCount
|
||||
case constant.FriendApplicationRejectedNotification:
|
||||
pushSwitch = config.Config.Notification.FriendApplicationRejected.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendApplicationRejected.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendApplicationRejected.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendApplicationRejected.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendApplicationRejected.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendApplicationRejected.Conversation.UnreadCount
|
||||
case constant.FriendAddedNotification:
|
||||
pushSwitch = config.Config.Notification.FriendAdded.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendAdded.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendAdded.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendAdded.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendAdded.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendAdded.Conversation.UnreadCount
|
||||
case constant.FriendDeletedNotification:
|
||||
pushSwitch = config.Config.Notification.FriendDeleted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendDeleted.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendDeleted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendDeleted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendDeleted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendDeleted.Conversation.UnreadCount
|
||||
case constant.FriendRemarkSetNotification:
|
||||
pushSwitch = config.Config.Notification.FriendRemarkSet.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendRemarkSet.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendRemarkSet.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendRemarkSet.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendRemarkSet.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendRemarkSet.Conversation.UnreadCount
|
||||
case constant.BlackAddedNotification:
|
||||
pushSwitch = config.Config.Notification.BlackAdded.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.BlackAdded.OfflinePush.Title
|
||||
desc = config.Config.Notification.BlackAdded.OfflinePush.Desc
|
||||
ex = config.Config.Notification.BlackAdded.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.BlackAdded.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.BlackAdded.Conversation.UnreadCount
|
||||
case constant.BlackDeletedNotification:
|
||||
pushSwitch = config.Config.Notification.BlackDeleted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.BlackDeleted.OfflinePush.Title
|
||||
desc = config.Config.Notification.BlackDeleted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.BlackDeleted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.BlackDeleted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.BlackDeleted.Conversation.UnreadCount
|
||||
case constant.ConversationOptChangeNotification:
|
||||
pushSwitch = config.Config.Notification.ConversationOptUpdate.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.ConversationOptUpdate.OfflinePush.Title
|
||||
desc = config.Config.Notification.ConversationOptUpdate.OfflinePush.Desc
|
||||
ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupDismissedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupDismissed.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupDismissed.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupDismissed.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupDismissed.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupDismissed.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupDismissed.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupMutedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupMuted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupMuted.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupMuted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupMuted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupMuted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupMuted.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupCancelMutedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupCancelMuted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupCancelMuted.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupCancelMuted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupCancelMuted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupCancelMuted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupCancelMuted.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupMemberMutedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupMemberMuted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupMemberMuted.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupMemberMuted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupMemberMuted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupMemberMuted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupMemberMuted.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupMemberCancelMutedNotification:
|
||||
pushSwitch = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
|
||||
|
||||
case constant.GroupMemberInfoSetNotification:
|
||||
pushSwitch = config.Config.Notification.GroupMemberInfoSet.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Title
|
||||
desc = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Desc
|
||||
ex = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.GroupMemberInfoSet.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.GroupMemberInfoSet.Conversation.UnreadCount
|
||||
|
||||
case constant.ConversationPrivateChatNotification:
|
||||
pushSwitch = config.Config.Notification.ConversationSetPrivate.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.ConversationSetPrivate.OfflinePush.Title
|
||||
desc = config.Config.Notification.ConversationSetPrivate.OfflinePush.Desc
|
||||
ex = config.Config.Notification.ConversationSetPrivate.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.ConversationSetPrivate.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.ConversationSetPrivate.Conversation.UnreadCount
|
||||
case constant.FriendInfoUpdatedNotification:
|
||||
pushSwitch = config.Config.Notification.FriendInfoUpdated.OfflinePush.PushSwitch
|
||||
title = config.Config.Notification.FriendInfoUpdated.OfflinePush.Title
|
||||
desc = config.Config.Notification.FriendInfoUpdated.OfflinePush.Desc
|
||||
ex = config.Config.Notification.FriendInfoUpdated.OfflinePush.Ext
|
||||
reliabilityLevel = config.Config.Notification.FriendInfoUpdated.Conversation.ReliabilityLevel
|
||||
unReadCount = config.Config.Notification.FriendInfoUpdated.Conversation.UnreadCount
|
||||
case constant.DeleteMessageNotification:
|
||||
reliabilityLevel = constant.ReliableNotificationNoMsg
|
||||
case constant.ConversationUnreadNotification, constant.SuperGroupUpdateNotification:
|
||||
reliabilityLevel = constant.UnreliableNotification
|
||||
}
|
||||
switch reliabilityLevel {
|
||||
case constant.UnreliableNotification:
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsPersistent, false)
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||
case constant.ReliableNotificationNoMsg:
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsSenderConversationUpdate, false)
|
||||
case constant.ReliableNotificationMsg:
|
||||
|
||||
}
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, unReadCount)
|
||||
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, pushSwitch)
|
||||
offlineInfo.Title = title
|
||||
offlineInfo.Desc = desc
|
||||
offlineInfo.Ex = ex
|
||||
msg.OfflinePushInfo = &offlineInfo
|
||||
req.MsgData = &msg
|
||||
_, err = c.Msg.SendMsg(ctx, &req)
|
||||
return err
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
pbFriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
||||
users, err := c.user.GetUsersInfoMap(ctx, []string{fromUserID, toUserID}, true)
|
||||
if err != nil {
|
||||
return "", "", nil
|
||||
}
|
||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||
}
|
||||
|
||||
func (c *Check) friendNotification(ctx context.Context, fromUserID, toUserID string, contentType int32, m proto.Message) {
|
||||
var err error
|
||||
var tips sdkws.TipsComm
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
marshaler := jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
EnumsAsInts: false,
|
||||
EmitDefaults: false,
|
||||
}
|
||||
|
||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||
|
||||
fromUserNickname, toUserNickname, err := c.getFromToUserNickname(ctx, fromUserID, toUserID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
cn := config.Config.Notification
|
||||
switch contentType {
|
||||
case constant.FriendApplicationNotification:
|
||||
tips.DefaultTips = fromUserNickname + cn.FriendApplication.DefaultTips.Tips
|
||||
case constant.FriendApplicationApprovedNotification:
|
||||
tips.DefaultTips = fromUserNickname + cn.FriendApplicationApproved.DefaultTips.Tips
|
||||
case constant.FriendApplicationRejectedNotification:
|
||||
tips.DefaultTips = fromUserNickname + cn.FriendApplicationRejected.DefaultTips.Tips
|
||||
case constant.FriendAddedNotification:
|
||||
tips.DefaultTips = cn.FriendAdded.DefaultTips.Tips
|
||||
case constant.FriendDeletedNotification:
|
||||
tips.DefaultTips = cn.FriendDeleted.DefaultTips.Tips + toUserNickname
|
||||
case constant.FriendRemarkSetNotification:
|
||||
tips.DefaultTips = fromUserNickname + cn.FriendRemarkSet.DefaultTips.Tips
|
||||
case constant.BlackAddedNotification:
|
||||
tips.DefaultTips = cn.BlackAdded.DefaultTips.Tips
|
||||
case constant.BlackDeletedNotification:
|
||||
tips.DefaultTips = cn.BlackDeleted.DefaultTips.Tips + toUserNickname
|
||||
case constant.UserInfoUpdatedNotification:
|
||||
tips.DefaultTips = cn.UserInfoUpdated.DefaultTips.Tips
|
||||
case constant.FriendInfoUpdatedNotification:
|
||||
tips.DefaultTips = cn.FriendInfoUpdated.DefaultTips.Tips + toUserNickname
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
var n NotificationMsg
|
||||
n.SendID = fromUserID
|
||||
n.RecvID = toUserID
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c.Notification(ctx, &n)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) {
|
||||
FriendApplicationTips := sdkws.FriendApplicationTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID
|
||||
c.friendNotification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
||||
FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||
c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
||||
FriendApplicationApprovedTips := sdkws.FriendApplicationApprovedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
||||
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
||||
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
||||
c.friendNotification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) {
|
||||
friendAddedTips := sdkws.FriendAddedTips{Friend: &sdkws.FriendInfo{}, OpUser: &sdkws.PublicUserInfo{}}
|
||||
user, err := c.user.GetUsersInfos(ctx, []string{opUserID}, true)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
friendAddedTips.OpUser.UserID = user[0].UserID
|
||||
friendAddedTips.OpUser.Ex = user[0].Ex
|
||||
friendAddedTips.OpUser.Nickname = user[0].Nickname
|
||||
friendAddedTips.OpUser.FaceURL = user[0].FaceURL
|
||||
|
||||
friend, err := c.friend.GetFriendsInfo(ctx, fromUserID, toUserID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
friendAddedTips.Friend = friend
|
||||
c.friendNotification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) {
|
||||
friendDeletedTips := sdkws.FriendDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) {
|
||||
friendInfoChangedTips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
||||
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
||||
c.friendNotification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
||||
}
|
||||
|
||||
func (c *Check) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) {
|
||||
blackAddedTips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
blackAddedTips.FromToUserID.ToUserID = req.BlackUserID
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips)
|
||||
}
|
||||
|
||||
func (c *Check) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
||||
blackDeletedTips := sdkws.BlackDeletedTips{FromToUserID: &sdkws.FromToUserID{}}
|
||||
blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
||||
blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID
|
||||
c.friendNotification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
||||
}
|
||||
|
||||
func (c *Check) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
|
||||
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
|
||||
c.friendNotification(ctx, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips)
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqs []int64, operationID string) {
|
||||
DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, Seqs: seqs}
|
||||
c.MessageNotification(ctx, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
|
||||
}
|
||||
|
||||
func (c *Check) MessageNotification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message) {
|
||||
var err error
|
||||
var tips sdkws.TipsComm
|
||||
tips.Detail, err = proto.Marshal(m)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
marshaler := jsonpb.Marshaler{
|
||||
OrigName: true,
|
||||
EnumsAsInts: false,
|
||||
EmitDefaults: false,
|
||||
}
|
||||
|
||||
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||
var n NotificationMsg
|
||||
n.SendID = sendID
|
||||
n.RecvID = recvID
|
||||
n.ContentType = contentType
|
||||
n.SessionType = constant.SingleChatType
|
||||
n.MsgFrom = constant.SysMsgType
|
||||
n.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c.Notification(ctx, &n)
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package notification
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
Loading…
Reference in new issue