mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-04 11:22:17 +08:00
update check
This commit is contained in:
parent
eaeb898db3
commit
3d427a8549
3
go.mod
3
go.mod
@ -156,3 +156,6 @@ require (
|
||||
golang.org/x/crypto v0.14.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
replace (
|
||||
github.com/OpenIMSDK/protocol v0.0.31 => github.com/AndrewZuo01/protocol v0.0.0-20231129091747-d1871b8baaa5
|
||||
)
|
||||
|
||||
@ -64,6 +64,9 @@ func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
|
||||
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.SetFriendRemark, o.Client, c)
|
||||
}
|
||||
func (o *FriendApi) SetPinFriends(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.PinFriends, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) AddBlack(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.AddBlack, o.Client, c)
|
||||
|
||||
@ -98,6 +98,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
||||
friendRouterGroup.POST("/is_friend", f.IsFriend)
|
||||
friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs)
|
||||
friendRouterGroup.POST("/get_specified_friends_info", f.GetSpecifiedFriendsInfo)
|
||||
friendRouterGroup.POST("/set_pin_friend", f.SetPinFriends)
|
||||
}
|
||||
g := NewGroupApi(*groupRpc)
|
||||
groupRouterGroup := r.Group("/group", ParseToken)
|
||||
|
||||
@ -70,6 +70,10 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||
return
|
||||
}
|
||||
if len(req.UserIDs) == 0 {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail("UserIDs array is empty").Wrap())
|
||||
return
|
||||
}
|
||||
conns, err := u.Discov.GetConns(c, config.Config.RpcRegisterName.OpenImMessageGatewayName)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, err)
|
||||
@ -134,6 +138,10 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||
return
|
||||
}
|
||||
if len(req.UserIDs) == 0 {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail("UserIDs array is empty").Wrap())
|
||||
return
|
||||
}
|
||||
conns, err := u.Discov.GetConns(c, config.Config.RpcRegisterName.OpenImMessageGatewayName)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, err)
|
||||
|
||||
@ -332,6 +332,34 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(
|
||||
resp.Total = int32(total)
|
||||
return resp, nil
|
||||
}
|
||||
func (s *friendServer) PinFriends(
|
||||
ctx context.Context,
|
||||
req *pbfriend.PinFriendsReq,
|
||||
) (*pbfriend.PinFriendsResp, error) {
|
||||
if len(req.FriendUserIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("friendIDList is empty")
|
||||
}
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friendIDList repeated")
|
||||
}
|
||||
|
||||
//檢查是不是在好友列表裏
|
||||
_, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//全部置頂
|
||||
//把所有friendslist的isPinned都設置為true
|
||||
for _, friendID := range req.FriendUserIDs {
|
||||
if err := s.friendDatabase.UpdateFriendPinStatus(ctx, req.OwnerUserID, friendID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resp := &pbfriend.PinFriendsResp{}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// ok.
|
||||
func (s *friendServer) IsFriend(
|
||||
|
||||
@ -78,6 +78,7 @@ type FriendDatabase interface {
|
||||
) (friends []*relation.FriendModel, err error)
|
||||
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
|
||||
FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*relation.FriendRequestModel, err error)
|
||||
UpdateFriendPinStatus(ctx context.Context, ownerUserID string, friendUserID string) (err error)
|
||||
}
|
||||
|
||||
type friendDatabase struct {
|
||||
@ -372,3 +373,11 @@ func (f *friendDatabase) FindFriendUserIDs(
|
||||
func (f *friendDatabase) FindBothFriendRequests(ctx context.Context, fromUserID, toUserID string) (friends []*relation.FriendRequestModel, err error) {
|
||||
return f.friendRequest.FindBothFriendRequests(ctx, fromUserID, toUserID)
|
||||
}
|
||||
|
||||
// 星標好友
|
||||
func (f *friendDatabase) UpdateFriendPinStatus(ctx context.Context, ownerUserID string, friendUserID string) (err error) {
|
||||
if err := f.friend.UpdatePinStatus(ctx, ownerUserID, friendUserID); err != nil {
|
||||
return err
|
||||
}
|
||||
return f.cache.DelFriend(ownerUserID, friendUserID).ExecDel(ctx)
|
||||
}
|
||||
|
||||
@ -75,4 +75,5 @@ type FriendModelInterface interface {
|
||||
// 获取好友UserID列表
|
||||
FindFriendUserIDs(ctx context.Context, ownerUserID string) (friendUserIDs []string, err error)
|
||||
NewTx(tx any) FriendModelInterface
|
||||
//UpdatePinStatus(ctx context.Context, ownerUserID string, friendUserID string) (err error)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user