This commit is contained in:
withchao 2023-04-26 15:16:56 +08:00
parent 122f649da7
commit cf39ea7364
3 changed files with 14 additions and 18 deletions

View File

@ -3,7 +3,6 @@ package notification
import ( import (
"context" "context"
"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/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws" "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
@ -25,7 +24,7 @@ func (c *ConversationNotificationSender) ConversationSetPrivateNotification(ctx
SendID: sendID, SendID: sendID,
IsPrivate: isPrivateChat, IsPrivate: isPrivateChat,
} }
return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationSetPrivate) return c.Notification(ctx, sendID, recvID, constant.ConversationPrivateChatNotification, constant.SingleChatType, tips)
} }
// 会话改变 // 会话改变
@ -33,7 +32,7 @@ func (c *ConversationNotificationSender) ConversationChangeNotification(ctx cont
tips := &sdkws.ConversationUpdateTips{ tips := &sdkws.ConversationUpdateTips{
UserID: userID, UserID: userID,
} }
return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationChanged) return c.Notification(ctx, userID, userID, constant.ConversationChangeNotification, constant.SingleChatType, tips)
} }
// 会话未读数同步 // 会话未读数同步
@ -43,5 +42,5 @@ func (c *ConversationNotificationSender) ConversationUnreadChangeNotification(ct
ConversationIDList: []string{conversationID}, ConversationIDList: []string{conversationID},
UpdateUnreadCountTime: updateUnreadCountTime, UpdateUnreadCountTime: updateUnreadCountTime,
} }
return c.Notification(ctx, userID, userID, constant.ConversationUnreadNotification, constant.SingleChatType, tips, config.Config.Notification.ConversationChanged) return c.Notification(ctx, userID, userID, constant.ConversationUnreadNotification, constant.SingleChatType, tips)
} }

View File

@ -2,8 +2,6 @@ package notification
import ( import (
"context" "context"
"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/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
@ -94,7 +92,7 @@ func (f *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fr
func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) error { func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) error {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
return f.Notification(ctx, opUserID, changedUserID, constant.SingleChatType, constant.UserInfoUpdatedNotification, &tips, config.Config.Notification.UserInfoUpdated) return f.Notification(ctx, opUserID, changedUserID, constant.SingleChatType, constant.UserInfoUpdatedNotification, &tips)
} }
func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) error { func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) error {
@ -102,7 +100,7 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.
FromUserID: req.FromUserID, FromUserID: req.FromUserID,
ToUserID: req.ToUserID, ToUserID: req.ToUserID,
}} }}
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.SingleChatType, constant.FriendApplicationNotification, &tips, config.Config.Notification.FriendApplication) return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.SingleChatType, constant.FriendApplicationNotification, &tips)
} }
func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error { func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
@ -110,7 +108,7 @@ func (c *FriendNotificationSender) FriendApplicationAgreedNotification(ctx conte
FromUserID: req.FromUserID, FromUserID: req.FromUserID,
ToUserID: req.ToUserID, ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg} }, HandleMsg: req.HandleMsg}
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.SingleChatType, constant.FriendApplicationApprovedNotification, &tips, config.Config.Notification.FriendApplicationApproved) return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.SingleChatType, constant.FriendApplicationApprovedNotification, &tips)
} }
func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error { func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) error {
@ -118,7 +116,7 @@ func (c *FriendNotificationSender) FriendApplicationRefusedNotification(ctx cont
FromUserID: req.FromUserID, FromUserID: req.FromUserID,
ToUserID: req.ToUserID, ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg} }, HandleMsg: req.HandleMsg}
return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.SingleChatType, constant.FriendApplicationRejectedNotification, &tips, config.Config.Notification.FriendApplicationRejected) return c.Notification(ctx, req.ToUserID, req.FromUserID, constant.SingleChatType, constant.FriendApplicationRejectedNotification, &tips)
} }
func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) error { func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) error {
@ -139,7 +137,7 @@ func (c *FriendNotificationSender) FriendAddedNotification(ctx context.Context,
if err != nil { if err != nil {
return err return err
} }
return c.Notification(ctx, fromUserID, toUserID, constant.SingleChatType, constant.FriendAddedNotification, &tips, config.Config.Notification.FriendAdded) return c.Notification(ctx, fromUserID, toUserID, constant.SingleChatType, constant.FriendAddedNotification, &tips)
} }
func (c *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error { func (c *FriendNotificationSender) FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) error {
@ -147,21 +145,21 @@ func (c *FriendNotificationSender) FriendDeletedNotification(ctx context.Context
FromUserID: req.OwnerUserID, FromUserID: req.OwnerUserID,
ToUserID: req.FriendUserID, ToUserID: req.FriendUserID,
}} }}
return c.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.SingleChatType, constant.FriendDeletedNotification, &tips, config.Config.Notification.FriendDeleted) return c.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.SingleChatType, constant.FriendDeletedNotification, &tips)
} }
func (c *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) error { func (c *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) error {
tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}} tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = fromUserID tips.FromToUserID.FromUserID = fromUserID
tips.FromToUserID.ToUserID = toUserID tips.FromToUserID.ToUserID = toUserID
return c.Notification(ctx, fromUserID, toUserID, constant.SingleChatType, constant.FriendRemarkSetNotification, &tips, config.Config.Notification.FriendRemarkSet) return c.Notification(ctx, fromUserID, toUserID, constant.SingleChatType, constant.FriendRemarkSetNotification, &tips)
} }
func (c *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error { func (c *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) error {
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = req.OwnerUserID tips.FromToUserID.FromUserID = req.OwnerUserID
tips.FromToUserID.ToUserID = req.BlackUserID tips.FromToUserID.ToUserID = req.BlackUserID
return c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.SingleChatType, constant.BlackAddedNotification, &tips, config.Config.Notification.BlackAdded) return c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.SingleChatType, constant.BlackAddedNotification, &tips)
} }
func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) { func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
@ -169,10 +167,10 @@ func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
FromUserID: req.OwnerUserID, FromUserID: req.OwnerUserID,
ToUserID: req.BlackUserID, ToUserID: req.BlackUserID,
}} }}
c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.SingleChatType, constant.BlackDeletedNotification, &blackDeletedTips, config.Config.Notification.BlackDeleted) c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.SingleChatType, constant.BlackDeletedNotification, &blackDeletedTips)
} }
func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
c.Notification(ctx, opUserID, needNotifiedUserID, constant.SingleChatType, constant.FriendInfoUpdatedNotification, &tips, config.Config.Notification.FriendInfoUpdated) c.Notification(ctx, opUserID, needNotifiedUserID, constant.SingleChatType, constant.FriendInfoUpdatedNotification, &tips)
} }

View File

@ -3,7 +3,6 @@ package notification
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
@ -354,7 +353,7 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
joinGroupApplicationTips := &sdkws.JoinGroupApplicationTips{Group: group, Applicant: user, ReqMsg: req.ReqMessage} joinGroupApplicationTips := &sdkws.JoinGroupApplicationTips{Group: group, Applicant: user, ReqMsg: req.ReqMessage}
for _, userID := range userIDs { for _, userID := range userIDs {
err := g.groupNotification(ctx, constant.JoinGroupApplicationNotification, joinGroupApplicationTips, mcontext.GetOpUserID(ctx), "", userID) err := g.groupNotification(ctx, constant.JoinGroupApplicationNotification, joinGroupApplicationTips, mcontext.GetOpUserID(ctx), "", userID)
err = g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.JoinGroupApplicationNotification, constant.SuperGroupChatType, joinGroupApplicationTips, config.Config.Notification.JoinGroupApplication) err = g.msgClient.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.JoinGroupApplicationNotification, constant.SuperGroupChatType, joinGroupApplicationTips)
if err != nil { if err != nil {
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID) log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
} }