mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 19:02:31 +08:00
update pin firend (unfinished)
This commit is contained in:
parent
c6a6bd8011
commit
1602a90c8b
15
go.mod
15
go.mod
@ -40,8 +40,13 @@ require (
|
||||
github.com/OpenIMSDK/protocol v0.0.31
|
||||
github.com/OpenIMSDK/tools v0.0.17
|
||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible
|
||||
github.com/aws/aws-sdk-go-v2 v1.23.1
|
||||
github.com/aws/aws-sdk-go-v2/config v1.25.4
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.16.3
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.43.1
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
github.com/qiniu/go-sdk/v7 v7.18.2
|
||||
github.com/redis/go-redis/v9 v9.2.1
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.45
|
||||
go.uber.org/automaxprocs v1.5.3
|
||||
@ -58,10 +63,7 @@ require (
|
||||
cloud.google.com/go/iam v1.1.2 // indirect
|
||||
cloud.google.com/go/longrunning v0.5.1 // indirect
|
||||
cloud.google.com/go/storage v1.30.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.23.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.25.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.16.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.4 // indirect
|
||||
@ -71,7 +73,6 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.43.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.17.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.20.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.25.4 // indirect
|
||||
@ -133,7 +134,6 @@ require (
|
||||
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
|
||||
github.com/prometheus/common v0.44.0 // indirect
|
||||
github.com/prometheus/procfs v0.11.1 // indirect
|
||||
github.com/qiniu/go-sdk/v7 v7.18.2 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rs/xid v1.5.0 // indirect
|
||||
github.com/sergi/go-diff v1.0.0 // indirect
|
||||
@ -174,7 +174,4 @@ require (
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
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
|
||||
)
|
||||
)
|
||||
2
go.sum
2
go.sum
@ -18,8 +18,6 @@ firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIw
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c=
|
||||
github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ=
|
||||
github.com/OpenIMSDK/protocol v0.0.31 h1:ax43x9aqA6EKNXNukS5MT5BSTqkUmwO4uTvbJLtzCgE=
|
||||
github.com/OpenIMSDK/protocol v0.0.31/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/OpenIMSDK/tools v0.0.17 h1:1E1HUOL2W09YUHBb4wBwrXoTSZm5ONVwLxlEX1GhlKw=
|
||||
github.com/OpenIMSDK/tools v0.0.17/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||
|
||||
@ -77,6 +77,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
||||
userRouterGroup.POST("/subscribe_users_status", ParseToken, u.SubscriberStatus)
|
||||
userRouterGroup.POST("/get_users_status", ParseToken, u.GetUserStatus)
|
||||
userRouterGroup.POST("/get_subscribe_users_status", ParseToken, u.GetSubscribeUsersStatus)
|
||||
userRouterGroup.POST("remove_user", ParseToken, u.RemoveUser)
|
||||
}
|
||||
// friend routing group
|
||||
friendRouterGroup := r.Group("/friend", ParseToken)
|
||||
|
||||
@ -207,3 +207,14 @@ func (u *UserApi) GetUserStatus(c *gin.Context) {
|
||||
func (u *UserApi) GetSubscribeUsersStatus(c *gin.Context) {
|
||||
a2r.Call(user.UserClient.GetSubscribeUsersStatus, u.Client, c)
|
||||
}
|
||||
func (u *UserApi) RemoveUser(c *gin.Context) {
|
||||
//刪除所有用戶相關的好友
|
||||
//用戶刪除了對方 但對方還有好友 特殊情況
|
||||
|
||||
//刪除所有用戶加入的群
|
||||
|
||||
//通訊錄好友,消息列表,朋友圈可能出bug
|
||||
//...
|
||||
|
||||
a2r.Call(user.UserClient.RemoveUser, u.Client, c)
|
||||
}
|
||||
|
||||
@ -342,6 +342,12 @@ func (s *friendServer) PinFriends(
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friendIDList repeated")
|
||||
}
|
||||
var isPinned bool
|
||||
if req.IsPinned != nil {
|
||||
isPinned = req.IsPinned.Value
|
||||
} else {
|
||||
return nil, errs.ErrArgs.Wrap("isPinned is nil")
|
||||
}
|
||||
|
||||
//檢查是不是在好友列表裏
|
||||
_, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
@ -352,7 +358,7 @@ func (s *friendServer) PinFriends(
|
||||
//全部置頂
|
||||
//把所有friendslist的isPinned都設置為true
|
||||
for _, friendID := range req.FriendUserIDs {
|
||||
if err := s.friendDatabase.UpdateFriendPinStatus(ctx, req.OwnerUserID, friendID); err != nil {
|
||||
if err := s.friendDatabase.UpdateFriendPinStatus(ctx, req.OwnerUserID, friendID, isPinned); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,3 +345,9 @@ func (s *userServer) GetSubscribeUsersStatus(ctx context.Context,
|
||||
}
|
||||
return &pbuser.GetSubscribeUsersStatusResp{StatusList: onlineStatusList}, nil
|
||||
}
|
||||
|
||||
// RemoveUser remove the user, user's friend relationship, and quit group
|
||||
func (s *userServer) RemoveUser(ctx context.Context, req *pbuser.RemoveUserReq) (*pbuser.RemoveUserResp, error) {
|
||||
|
||||
return &pbuser.RemoveUserResp{}, nil
|
||||
}
|
||||
|
||||
@ -78,7 +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)
|
||||
UpdateFriendPinStatus(ctx context.Context, ownerUserID string, friendUserID string, isPinned bool) (err error)
|
||||
}
|
||||
|
||||
type friendDatabase struct {
|
||||
@ -375,8 +375,8 @@ func (f *friendDatabase) FindBothFriendRequests(ctx context.Context, fromUserID,
|
||||
}
|
||||
|
||||
// 星標好友
|
||||
func (f *friendDatabase) UpdateFriendPinStatus(ctx context.Context, ownerUserID string, friendUserID string) (err error) {
|
||||
if err := f.friend.UpdatePinStatus(ctx, ownerUserID, friendUserID); err != nil {
|
||||
func (f *friendDatabase) UpdateFriendPinStatus(ctx context.Context, ownerUserID string, friendUserID string, isPinned bool) (err error) {
|
||||
if err := f.friend.UpdatePinStatus(ctx, ownerUserID, friendUserID, isPinned); err != nil {
|
||||
return err
|
||||
}
|
||||
return f.cache.DelFriend(ownerUserID, friendUserID).ExecDel(ctx)
|
||||
|
||||
@ -191,3 +191,13 @@ func (f *FriendGorm) FindFriendUserIDs(ctx context.Context, ownerUserID string)
|
||||
"",
|
||||
)
|
||||
}
|
||||
func (f *FriendGorm) UpdatePinStatus(ctx context.Context, ownerUserID string, friendUserID string, isPinned bool) (err error) {
|
||||
return utils.Wrap(
|
||||
f.db(ctx).
|
||||
Model(&relation.FriendModel{}).
|
||||
Where("owner_user_id = ? AND friend_user_id = ?", ownerUserID, friendUserID).
|
||||
Update("is_pinned", isPinned).
|
||||
Error,
|
||||
"UpdatePinStatus failed",
|
||||
)
|
||||
}
|
||||
|
||||
@ -75,5 +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)
|
||||
UpdatePinStatus(ctx context.Context, ownerUserID string, friendUserID string, isPinned bool) (err error)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user