mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-11 04:25:59 +08:00
add GetSpecifiedFriendsInfo (#986)
* fix: create group type limit * fix: group notification * fix: group notification * fix: group notification * chore: group member hash * chore: group member hash * chore: group member hash * chore: group member hash * test: log * test: log * test: log * test: log * test: log * sync: hash code * sync: hash code * sync: hash code * test: log * test: log * test: log * test: log * test: log * fix: time stamp * fix: minio sign endpoint opts * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: minio bucket url * fix: op user info * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Conversation * fix: importFriends Notification * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: importFriends Notification * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * NotificationUserInfoUpdate * TransferGroupOwner del group hash * add GetSpecifiedFriendsInfo * cicd: robot automated Change Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: withchao <withchao@users.noreply.github.com>
This commit is contained in:
@@ -88,3 +88,7 @@ func (o *FriendApi) IsFriend(c *gin.Context) {
|
||||
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetFriendIDs, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetSpecifiedFriendsInfo, o.Client, c)
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
||||
friendRouterGroup.POST("/import_friend", f.ImportFriends)
|
||||
friendRouterGroup.POST("/is_friend", f.IsFriend)
|
||||
friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs)
|
||||
friendRouterGroup.POST("/get_specified_friends_info", f.GetSpecifiedFriendsInfo)
|
||||
}
|
||||
g := NewGroupApi(*groupRpc)
|
||||
groupRouterGroup := r.Group("/group", ParseToken)
|
||||
|
||||
@@ -17,6 +17,8 @@ package friend
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
@@ -357,3 +359,66 @@ func (s *friendServer) GetFriendIDs(
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfriend.GetSpecifiedFriendsInfoReq) (*pbfriend.GetSpecifiedFriendsInfoResp, error) {
|
||||
if len(req.UserIDList) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("userIDList is empty")
|
||||
}
|
||||
if utils.Duplicate(req.UserIDList) {
|
||||
return nil, errs.ErrArgs.Wrap("userIDList repeated")
|
||||
}
|
||||
userMap, err := s.userRpcClient.GetUsersInfoMap(ctx, req.UserIDList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friends, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.UserIDList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blacks, err := s.blackDatabase.FindBlackInfos(ctx, req.OwnerUserID, req.UserIDList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
friendMap := utils.SliceToMap(friends, func(e *tablerelation.FriendModel) string {
|
||||
return e.FriendUserID
|
||||
})
|
||||
blackMap := utils.SliceToMap(blacks, func(e *tablerelation.BlackModel) string {
|
||||
return e.BlockUserID
|
||||
})
|
||||
resp := &pbfriend.GetSpecifiedFriendsInfoResp{
|
||||
Infos: make([]*pbfriend.GetSpecifiedFriendsInfoInfo, 0, len(req.UserIDList)),
|
||||
}
|
||||
for _, userID := range req.UserIDList {
|
||||
user := userMap[userID]
|
||||
if user == nil {
|
||||
continue
|
||||
}
|
||||
var friendInfo *sdkws.FriendInfo
|
||||
if friend := friendMap[userID]; friend != nil {
|
||||
friendInfo = &sdkws.FriendInfo{
|
||||
OwnerUserID: friend.OwnerUserID,
|
||||
Remark: friend.Remark,
|
||||
CreateTime: friend.CreateTime.UnixMilli(),
|
||||
AddSource: friend.AddSource,
|
||||
OperatorUserID: friend.OperatorUserID,
|
||||
Ex: friend.Ex,
|
||||
}
|
||||
}
|
||||
var blackInfo *sdkws.BlackInfo
|
||||
if black := blackMap[userID]; black != nil {
|
||||
blackInfo = &sdkws.BlackInfo{
|
||||
OwnerUserID: black.OwnerUserID,
|
||||
CreateTime: black.CreateTime.UnixMilli(),
|
||||
AddSource: black.AddSource,
|
||||
OperatorUserID: black.OperatorUserID,
|
||||
Ex: black.Ex,
|
||||
}
|
||||
}
|
||||
resp.Infos = append(resp.Infos, &pbfriend.GetSpecifiedFriendsInfoInfo{
|
||||
UserInfo: user,
|
||||
FriendInfo: friendInfo,
|
||||
BlackInfo: blackInfo,
|
||||
})
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user