mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-28 21:19:02 +08:00
Error code standardization
This commit is contained in:
parent
4067d7e4b9
commit
e7eee16cf1
11
internal/common/check/friend.go
Normal file
11
internal/common/check/friend.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package check
|
||||||
|
|
||||||
|
import (
|
||||||
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetFriendsInfo(ctx context.Context, ownerUserID, friendUserID string) (*server_api_params.FriendInfo, error) {
|
||||||
|
return nil, errors.New("TODO:GetUserInfo")
|
||||||
|
}
|
@ -4,9 +4,7 @@ import (
|
|||||||
"Open_IM/internal/common/check"
|
"Open_IM/internal/common/check"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
utils2 "Open_IM/pkg/common/utils"
|
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
@ -115,21 +113,22 @@ func FriendApplicationRejectedNotification(operationID string, req *pbFriend.Res
|
|||||||
friendNotification(operationID, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
friendNotification(operationID, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &FriendApplicationApprovedTips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FriendAddedNotification(operationID, opUserID, fromUserID, toUserID string) {
|
func FriendAddedNotification(ctx context.Context, operationID, opUserID, fromUserID, toUserID string) {
|
||||||
friendAddedTips := open_im_sdk.FriendAddedTips{Friend: &open_im_sdk.FriendInfo{}, OpUser: &open_im_sdk.PublicUserInfo{}}
|
friendAddedTips := open_im_sdk.FriendAddedTips{Friend: &open_im_sdk.FriendInfo{}, OpUser: &open_im_sdk.PublicUserInfo{}}
|
||||||
user, err := imdb.GetUserByUserID(opUserID)
|
user, err := check.GetUsersInfo(context.Background(), opUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, "GetUserByUserID failed ", err.Error(), opUserID)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils2.UserDBCopyOpenIMPublicUser(friendAddedTips.OpUser, user)
|
friendAddedTips.OpUser.UserID = user[0].UserID
|
||||||
friend, err := imdb.GetFriendRelationshipFromFriend(fromUserID, toUserID)
|
friendAddedTips.OpUser.Ex = user[0].Ex
|
||||||
if err != nil {
|
friendAddedTips.OpUser.Nickname = user[0].Nickname
|
||||||
log.NewError(operationID, "GetFriendRelationshipFromFriend failed ", err.Error(), fromUserID, toUserID)
|
friendAddedTips.OpUser.FaceURL = user[0].FaceURL
|
||||||
return
|
|
||||||
}
|
|
||||||
utils2.FriendDBCopyOpenIM(friendAddedTips.Friend, friend)
|
|
||||||
|
|
||||||
|
friend, err := check.GetFriendsInfo(ctx, fromUserID, toUserID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
friendAddedTips.Friend = friend
|
||||||
friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
friendNotification(operationID, fromUserID, toUserID, constant.FriendAddedNotification, &friendAddedTips)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user