|
|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
|
"Open_IM/pkg/common/tracelog"
|
|
|
|
|
pbFriend "Open_IM/pkg/proto/friend"
|
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
|
"Open_IM/pkg/utils"
|
|
|
|
@ -90,27 +91,27 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in
|
|
|
|
|
Notification(&n)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendApplicationNotification(operationID string, req *pbFriend.AddFriendReq) {
|
|
|
|
|
func FriendApplicationNotification(ctx context.Context, req *pbFriend.AddFriendReq) {
|
|
|
|
|
FriendApplicationTips := open_im_sdk.FriendApplicationTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID
|
|
|
|
|
FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID
|
|
|
|
|
friendNotification(operationID, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendApplicationApprovedNotification(operationID string, req *pbFriend.RespondFriendApplyReq) {
|
|
|
|
|
func FriendApplicationApprovedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
|
|
|
|
FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
|
|
|
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
|
|
|
|
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
|
|
|
|
friendNotification(operationID, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendApplicationRejectedNotification(operationID string, req *pbFriend.RespondFriendApplyReq) {
|
|
|
|
|
func FriendApplicationRejectedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) {
|
|
|
|
|
FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID
|
|
|
|
|
FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID
|
|
|
|
|
FriendApplicationApprovedTips.HandleMsg = req.HandleMsg
|
|
|
|
|
friendNotification(operationID, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) {
|
|
|
|
@ -132,41 +133,41 @@ func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUse
|
|
|
|
|
friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendDeletedNotification(operationID string, req *pbFriend.DeleteFriendReq) {
|
|
|
|
|
func FriendDeletedNotification(ctx context.Context, req *pbFriend.DeleteFriendReq) {
|
|
|
|
|
friendDeletedTips := open_im_sdk.FriendDeletedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
friendDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
|
|
|
|
friendDeletedTips.FromToUserID.ToUserID = req.FriendUserID
|
|
|
|
|
friendNotification(operationID, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &friendDeletedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendRemarkSetNotification(operationID, fromUserID, toUserID string) {
|
|
|
|
|
func FriendRemarkSetNotification(ctx context.Context, fromUserID, toUserID string) {
|
|
|
|
|
friendInfoChangedTips := open_im_sdk.FriendInfoChangedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
friendInfoChangedTips.FromToUserID.FromUserID = fromUserID
|
|
|
|
|
friendInfoChangedTips.FromToUserID.ToUserID = toUserID
|
|
|
|
|
friendNotification(operationID, fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), fromUserID, toUserID, constant.FriendRemarkSetNotification, &friendInfoChangedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BlackAddedNotification(operationID string, req *pbFriend.AddBlackReq) {
|
|
|
|
|
func BlackAddedNotification(ctx context.Context, req *pbFriend.AddBlackReq) {
|
|
|
|
|
blackAddedTips := open_im_sdk.BlackAddedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
blackAddedTips.FromToUserID.FromUserID = req.OwnerUserID
|
|
|
|
|
blackAddedTips.FromToUserID.ToUserID = req.BlackUserID
|
|
|
|
|
friendNotification(operationID, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &blackAddedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func BlackDeletedNotification(operationID string, req *pbFriend.RemoveBlackReq) {
|
|
|
|
|
func BlackDeletedNotification(ctx context.Context, req *pbFriend.RemoveBlackReq) {
|
|
|
|
|
blackDeletedTips := open_im_sdk.BlackDeletedTips{FromToUserID: &open_im_sdk.FromToUserID{}}
|
|
|
|
|
blackDeletedTips.FromToUserID.FromUserID = req.OwnerUserID
|
|
|
|
|
blackDeletedTips.FromToUserID.ToUserID = req.BlackUserID
|
|
|
|
|
friendNotification(operationID, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// send to myself
|
|
|
|
|
func UserInfoUpdatedNotification(operationID, opUserID string, changedUserID string) {
|
|
|
|
|
func UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) {
|
|
|
|
|
selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: changedUserID}
|
|
|
|
|
friendNotification(operationID, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), opUserID, changedUserID, constant.UserInfoUpdatedNotification, &selfInfoUpdatedTips)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FriendInfoUpdatedNotification(operationID, changedUserID string, needNotifiedUserID string, opUserID string) {
|
|
|
|
|
func FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) {
|
|
|
|
|
selfInfoUpdatedTips := open_im_sdk.UserInfoUpdatedTips{UserID: changedUserID}
|
|
|
|
|
friendNotification(operationID, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips)
|
|
|
|
|
friendNotification(tracelog.GetOperationID(ctx), opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &selfInfoUpdatedTips)
|
|
|
|
|
}
|
|
|
|
|