Refactor code

pull/141/head
wenxu12345 3 years ago
parent 3380cab2c3
commit 9077b56df1

@ -179,7 +179,7 @@ notification:
groupCreated:
conversation:
reliabilityLevel: 1
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: true
@ -191,111 +191,111 @@ notification:
groupInfoSet:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "groupInfoSet title"
desc: "groupInfoSet desc"
ext: "groupInfoSet ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "modified the group profile" # group info changed by xx
joinGroupApplication:
conversation:
reliabilityLevel: 1
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "joinGroupApplication title"
desc: "joinGroupApplication desc"
ext: "joinGroupApplication ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "apply to join the group" # group info changed by xx
memberQuit:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "memberQuit title"
desc: "memberQuit desc"
ext: "memberQuit ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "quit group chat" # group info changed by xx
groupApplicationAccepted:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "groupApplicationAccepted title"
desc: "groupApplicationAccepted desc"
ext: "groupApplicationAccepted ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "was allowed to join the group" # group info changed by xx
groupApplicationRejected:
conversation:
reliabilityLevel: 1
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: " title"
desc: " desc"
ext: " ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "was rejected into the group" # group info changed by xx
groupOwnerTransferred:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "groupOwnerTransferred title"
desc: "groupOwnerTransferred desc"
ext: "groupOwnerTransferred ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "become a new group owner" # group info changed by xx
memberKicked:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "memberKicked title"
desc: "memberKicked desc"
ext: "memberKicked ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "was kicked out of the group" # group info changed by xx
memberInvited:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "memberInvited title"
desc: "memberInvited desc"
ext: "memberInvited ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "was invited into the group" # group info changed by xx
memberEnter:
conversation:
reliabilityLevel: 1
unreadCount: false
reliabilityLevel: 3
unreadCount: true
offlinePush:
switch: false
title: "group info changed title"
desc: "group info changed desc"
ext: "group info changed ext"
title: "memberEnter title"
desc: "memberEnter desc"
ext: "memberEnter ext"
defaultTips:
tips: "group info changed by" # group info changed by xx
tips: "entered the group" # group info changed by xx
#############################friend#################################

@ -94,18 +94,44 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv
return
}
from, err := imdb.GetUserByUserID(sendID)
if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error())
}
nickname := ""
if from != nil {
nickname = from.Nickname
}
to, err := imdb.GetUserByUserID(recvUserID)
if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error())
}
toNickname := ""
if from != nil {
toNickname = to.Nickname
}
cn := config.Config.Notification
switch contentType {
case constant.GroupCreatedNotification:
tips.DefaultTips = cn.GroupCreated.DefaultTips.Tips
tips.DefaultTips = nickname + " " + cn.GroupCreated.DefaultTips.Tips
case constant.GroupInfoSetNotification:
tips.DefaultTips = nickname + " " + cn.GroupInfoSet.DefaultTips.Tips
case constant.JoinGroupApplicationNotification:
tips.DefaultTips = nickname + " " + cn.JoinGroupApplication.DefaultTips.Tips
case constant.MemberQuitNotification:
case constant.GroupApplicationAcceptedNotification:
case constant.GroupApplicationRejectedNotification:
case constant.GroupOwnerTransferredNotification:
case constant.MemberKickedNotification:
case constant.MemberInvitedNotification:
tips.DefaultTips = nickname + " " + cn.MemberQuit.DefaultTips.Tips
case constant.GroupApplicationAcceptedNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupApplicationAccepted.DefaultTips.Tips
case constant.GroupApplicationRejectedNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupApplicationRejected.DefaultTips.Tips
case constant.GroupOwnerTransferredNotification: //
tips.DefaultTips = toNickname + " " + cn.GroupOwnerTransferred.DefaultTips.Tips
case constant.MemberKickedNotification: //
tips.DefaultTips = toNickname + " " + cn.MemberKicked.DefaultTips.Tips
case constant.MemberInvitedNotification: //
tips.DefaultTips = toNickname + " " + cn.MemberInvited.DefaultTips.Tips
default:
log.Error(operationID, "contentType failed ", contentType)
return

Loading…
Cancel
Save