notification

This commit is contained in:
wangchuxiao 2023-04-23 21:14:40 +08:00
parent f6cebdbdef
commit 0071252777
7 changed files with 94 additions and 466 deletions

View File

@ -10,10 +10,6 @@ groupCreated:
# 加消息contentType老的作为通知的 content统一json 结构体使用pb的
groupInfoSet:
conversation:
reliabilityLevel: 3
@ -199,155 +195,113 @@ groupMemberInfoSet:
#############################friend#################################
friendApplicationAdded:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: false
title: "Somebody applies to add you as a friend"
desc: "Somebody applies to add you as a friend"
ext: "Somebody applies to add you as a friend"
defaultTips:
tips: "I applies to add you as a friend" #
friendApplicationApproved:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "Someone applies to add your friend application"
desc: "Someone applies to add your friend application"
ext: "Someone applies to add your friend application"
defaultTips:
tips: "I applies to add your friend application" #
friendApplicationRejected:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "Someone rejected your friend application"
desc: "Someone rejected your friend application"
ext: "Someone rejected your friend application"
defaultTips:
tips: "I rejected your friend application" #
friendAdded:
conversation:
reliabilityLevel: 3
unreadCount: true
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "We have become friends"
desc: "We have become friends"
ext: "We have become friends"
defaultTips:
tips: "We have become friends" #
friendDeleted:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "deleted a friend"
desc: "deleted a friend"
ext: "deleted a friend"
defaultTips:
tips: "deleted a friend" #
friendRemarkSet:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "Your friend's profile has been changed"
desc: "Your friend's profile has been changed"
ext: "Your friend's profile has been changed"
defaultTips:
tips: "Your friend's profile has been changed" #
blackAdded:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "blocked a user"
desc: "blocked a user"
ext: "blocked a user"
defaultTips:
tips: "blocked a user" #
blackDeleted:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
defaultTips:
tips: "Remove a blocked user"
friendInfoUpdated:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "friend info updated"
desc: "friend info updated"
ext: "friend info updated"
defaultTips:
tips: "friend info updated"
#####################user#########################
userInfoUpdated:
conversation:
reliabilityLevel: 2
unreadCount: false
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "Remove a blocked user"
desc: "Remove a blocked user"
ext: "Remove a blocked user"
defaultTips:
tips: "remove a blocked user"
#####################conversation#########################
conversationOptUpdate:
conversation:
reliabilityLevel: 1
unreadCount: false
offlinePush:
switch: true
title: "conversation opt update"
desc: "conversation opt update"
ext: "conversation opt update"
defaultTips:
tips: "conversation opt update"
isSendMsg: true
unreadCount: false
offlinePush:
enable: true
title: "conversation opt update"
desc: "conversation opt update"
ext: "conversation opt update"
conversationSetPrivate:
conversation:
reliabilityLevel: 3
unreadCount: true
isSendMsg: true
unreadCount: false
offlinePush:
switch: true
enable: true
title: "burn after reading"
desc: "burn after reading"
ext: "burn after reading"
defaultTips:
openTips: "burn after reading was opened"
closeTips: "burn after reading was closed"

View File

@ -39,20 +39,17 @@ type CallBackConfig struct {
CallbackFailedContinue *bool `yaml:"callbackFailedContinue"`
}
type PConversation struct {
ReliabilityLevel int `yaml:"reliabilityLevel"`
UnreadCount bool `yaml:"unreadCount"`
type NotificationConf struct {
IsSendMsg bool `yaml:"isSendMsg"`
UnreadCount bool `yaml:"unreadCount"`
OfflinePush POfflinePush `yaml:"offlinePush"`
}
type POfflinePush struct {
PushSwitch bool `yaml:"switch"`
Title string `yaml:"title"`
Desc string `yaml:"desc"`
Ext string `yaml:"ext"`
}
type PDefaultTips struct {
Tips string `yaml:"tips"`
Enable bool `yaml:"enable"`
Title string `yaml:"title"`
Desc string `yaml:"desc"`
Ext string `yaml:"ext"`
}
type config struct {
@ -320,181 +317,39 @@ type config struct {
}
type Notification struct {
GroupCreated struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupCreated"`
GroupInfoSet struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupInfoSet"`
JoinGroupApplication struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"joinGroupApplication"`
MemberQuit struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"memberQuit"`
GroupApplicationAccepted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupApplicationAccepted"`
GroupApplicationRejected struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupApplicationRejected"`
GroupOwnerTransferred struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupOwnerTransferred"`
MemberKicked struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"memberKicked"`
MemberInvited struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"memberInvited"`
MemberEnter struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"memberEnter"`
GroupDismissed struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupDismissed"`
GroupMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMuted"`
GroupCancelMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupCancelMuted"`
GroupMemberMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberMuted"`
GroupMemberCancelMuted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberCancelMuted"`
GroupMemberInfoSet struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberInfoSet"`
GroupMemberSetToAdmin struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberSetToAdmin"`
GroupMemberSetToOrdinary struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberSetToOrdinaryUser"`
GroupCreated NotificationConf `yaml:"groupCreated"`
GroupInfoSet NotificationConf `yaml:"groupInfoSet"`
JoinGroupApplication NotificationConf `yaml:"joinGroupApplication"`
MemberQuit NotificationConf `yaml:"memberQuit"`
GroupApplicationAccepted NotificationConf `yaml:"groupApplicationAccepted"`
GroupApplicationRejected NotificationConf `yaml:"groupApplicationRejected"`
GroupOwnerTransferred NotificationConf `yaml:"groupOwnerTransferred"`
MemberKicked NotificationConf `yaml:"memberKicked"`
MemberInvited NotificationConf `yaml:"memberInvited"`
MemberEnter NotificationConf `yaml:"memberEnter"`
GroupDismissed NotificationConf `yaml:"groupDismissed"`
GroupMuted NotificationConf `yaml:"groupMuted"`
GroupCancelMuted NotificationConf `yaml:"groupCancelMuted"`
GroupMemberMuted NotificationConf `yaml:"groupMemberMuted"`
GroupMemberCancelMuted NotificationConf `yaml:"groupMemberCancelMuted"`
GroupMemberInfoSet NotificationConf `yaml:"groupMemberInfoSet"`
GroupMemberSetToAdmin NotificationConf `yaml:"groupMemberSetToAdmin"`
GroupMemberSetToOrdinary NotificationConf `yaml:"groupMemberSetToOrdinaryUser"`
////////////////////////user///////////////////////
UserInfoUpdated struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"userInfoUpdated"`
UserInfoUpdated NotificationConf `yaml:"userInfoUpdated"`
//////////////////////friend///////////////////////
FriendApplication struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendApplicationAdded"`
FriendApplicationApproved struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendApplicationApproved"`
FriendApplicationRejected struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendApplicationRejected"`
FriendAdded struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendAdded"`
FriendDeleted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendDeleted"`
FriendRemarkSet struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendRemarkSet"`
BlackAdded struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"blackAdded"`
BlackDeleted struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"blackDeleted"`
FriendInfoUpdated struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"friendInfoUpdated"`
ConversationOptUpdate struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"conversationOptUpdate"`
ConversationSetPrivate struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips struct {
OpenTips string `yaml:"openTips"`
CloseTips string `yaml:"closeTips"`
} `yaml:"defaultTips"`
} `yaml:"conversationSetPrivate"`
FriendApplication NotificationConf `yaml:"friendApplicationAdded"`
FriendApplicationApproved NotificationConf `yaml:"friendApplicationApproved"`
FriendApplicationRejected NotificationConf `yaml:"friendApplicationRejected"`
FriendAdded NotificationConf `yaml:"friendAdded"`
FriendDeleted NotificationConf `yaml:"friendDeleted"`
FriendRemarkSet NotificationConf `yaml:"friendRemarkSet"`
BlackAdded NotificationConf `yaml:"blackAdded"`
BlackDeleted NotificationConf `yaml:"blackDeleted"`
FriendInfoUpdated NotificationConf `yaml:"friendInfoUpdated"`
//////////////////////conversation///////////////////////
ConversationOptUpdate NotificationConf `yaml:"conversationOptUpdate"`
ConversationSetPrivate NotificationConf `yaml:"conversationSetPrivate"`
}
func (c *config) unmarshalConfig(config interface{}, configPath string) error {

View File

@ -275,11 +275,6 @@ const CheckKey = "CheckKey"
const TriggerID = "triggerID"
const RemoteAddr = "remoteAddr"
const (
UnreliableNotification = 1
ReliableNotificationNoMsg = 2
ReliableNotificationMsg = 3
)
const (
BecomeFriendByImport = 1 //管理员导入
BecomeFriendByApply = 2 //申请添加

View File

@ -22,10 +22,6 @@ func (m *MetaClient) getConn() (*grpc.ClientConn, error) {
return m.client.GetConn(m.rpcRegisterName)
}
func (m *MetaClient) getRpcRegisterName() string {
return m.rpcRegisterName
}
type NotificationMsg struct {
SendID string
RecvID string

View File

@ -52,8 +52,7 @@ func (c *MsgClient) Notification(ctx context.Context, notificationMsg *Notificat
var msg sdkws.MsgData
var offlineInfo sdkws.OfflinePushInfo
var title, desc, ex string
var pushSwitch, unReadCount bool
var reliabilityLevel int
var pushEnable, unReadCount bool
msg.SendID = notificationMsg.SendID
msg.RecvID = notificationMsg.RecvID
msg.Content = notificationMsg.Content
@ -74,227 +73,124 @@ func (c *MsgClient) Notification(ctx context.Context, notificationMsg *Notificat
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)
utils.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, pushEnable)
offlineInfo.Title = title
offlineInfo.Desc = desc
offlineInfo.Ex = ex

View File

@ -2,13 +2,12 @@ package notification2
import (
"context"
"encoding/json"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
@ -20,25 +19,15 @@ func NewConversationNotificationSender(client discoveryregistry.SvcDiscoveryRegi
return &ConversationNotificationSender{rpcclient.NewMsgClient(client)}
}
func (c *ConversationNotificationSender) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message, tips *sdkws.TipsComm) {
func (c *ConversationNotificationSender) SetConversationNotification(ctx context.Context, sendID, recvID string, contentType int, m proto.Message) {
var err error
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 rpcclient.NotificationMsg
n.SendID = sendID
n.RecvID = recvID
n.ContentType = int32(contentType)
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.Content, err = proto.Marshal(tips)
n.Content, err = json.Marshal(m)
if err != nil {
return
}
@ -47,40 +36,28 @@ func (c *ConversationNotificationSender) SetConversationNotification(ctx context
// SetPrivate调用
func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx context.Context, sendID, recvID string, isPrivateChat bool) {
conversationSetPrivateTips := &sdkws.ConversationSetPrivateTips{
tips := &sdkws.ConversationSetPrivateTips{
RecvID: recvID,
SendID: sendID,
IsPrivate: isPrivateChat,
}
var tips sdkws.TipsComm
var tipsMsg string
if isPrivateChat == true {
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.OpenTips
} else {
tipsMsg = config.Config.Notification.ConversationSetPrivate.DefaultTips.CloseTips
}
tips.DefaultTips = tipsMsg
c.SetConversationNotification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, conversationSetPrivateTips, &tips)
c.SetConversationNotification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, tips)
}
// 会话改变
func (c *ConversationNotificationSender) ConversationChangeNotification(ctx context.Context, userID string) {
ConversationChangedTips := &sdkws.ConversationUpdateTips{
tips := &sdkws.ConversationUpdateTips{
UserID: userID,
}
var tips sdkws.TipsComm
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
c.SetConversationNotification(ctx, userID, userID, constant.ConversationOptChangeNotification, ConversationChangedTips, &tips)
c.SetConversationNotification(ctx, userID, userID, constant.ConversationOptChangeNotification, tips)
}
// 会话未读数同步
func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(ctx context.Context, userID, conversationID string, updateUnreadCountTime int64) {
ConversationChangedTips := &sdkws.ConversationUpdateTips{
tips := &sdkws.ConversationUpdateTips{
UserID: userID,
ConversationIDList: []string{conversationID},
UpdateUnreadCountTime: updateUnreadCountTime,
}
var tips sdkws.TipsComm
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
c.SetConversationNotification(ctx, userID, userID, constant.ConversationUnreadNotification, ConversationChangedTips, &tips)
c.SetConversationNotification(ctx, userID, userID, constant.ConversationUnreadNotification, tips)
}

View File

@ -2,8 +2,8 @@ package notification2
import (
"context"
"encoding/json"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
@ -12,7 +12,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/convert"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
@ -96,56 +95,13 @@ func (c *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fr
func (c *FriendNotificationSender) 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 rpcclient.NotificationMsg
n.SendID = fromUserID
n.RecvID = toUserID
n.ContentType = contentType
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.Content, err = proto.Marshal(&tips)
n.Content, err = json.Marshal(m)
if err != nil {
return
}
@ -153,8 +109,8 @@ func (c *FriendNotificationSender) friendNotification(ctx context.Context, fromU
}
func (u *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) {
selfInfoUpdatedTips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
u.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
u.friendNotification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &tips)
}
func (c *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) {
@ -190,7 +146,6 @@ func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context,
friendAddedTips.OpUser.Ex = user[0].GetEx()
friendAddedTips.OpUser.Nickname = user[0].GetNickname()
friendAddedTips.OpUser.FaceURL = user[0].GetFaceURL()
friends, err := c.db.FindFriendsWithError(ctx, fromUserID, []string{toUserID})
if err != nil {
return