mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-09 19:45:58 +08:00
Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc5fa648de | |||
| 263ab752dd | |||
| cf0ef7652a | |||
| 709d772233 | |||
| c9df323da4 | |||
| 22df23cf8b | |||
| 0031aeca02 | |||
| 67e6e789ec | |||
| 9fdb85d354 | |||
| 8b2bfba89b | |||
| 2934535c18 | |||
| 9b9bfae857 | |||
| 32edd4b17c | |||
| d5651ae1d8 | |||
| 8aad2cf300 | |||
| 4bf4eb5464 | |||
| e66e490ae6 | |||
| 1d6d163da0 | |||
| 8e1bb9abb9 | |||
| d26e2594f2 | |||
| 5893181226 | |||
| e2b581f2cc | |||
| 2531091742 | |||
| 9d42a2abc2 | |||
| 0ff8402c83 | |||
| 76484e09ac | |||
| 8c2e7c1fdc | |||
| d62fedcabb | |||
| 4d89bba8c0 | |||
| 8da0c53523 | |||
| 96e09a1b37 | |||
| 786090f742 |
@@ -393,6 +393,14 @@ archives:
|
|||||||
{{- else if eq .Arch "386" }}i386
|
{{- else if eq .Arch "386" }}i386
|
||||||
{{- else }}{{ .Arch }}{{ end }}
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
|
||||||
|
# Set this to true if you want all files in the archive to be in a single directory.
|
||||||
|
# If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz',
|
||||||
|
# you'll get a folder 'goreleaser_Linux_arm64'.
|
||||||
|
# If set to false, all files are extracted separately.
|
||||||
|
# You can also set it to a custom folder name (templating is supported).
|
||||||
|
wrap_in_directory: true
|
||||||
|
|
||||||
# use zip for windows archives
|
# use zip for windows archives
|
||||||
files:
|
files:
|
||||||
- CHANGELOG/*
|
- CHANGELOG/*
|
||||||
@@ -406,13 +414,6 @@ archives:
|
|||||||
- src: "*.md"
|
- src: "*.md"
|
||||||
dst: docs
|
dst: docs
|
||||||
|
|
||||||
# Set this to true if you want all files in the archive to be in a single directory.
|
|
||||||
# If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz',
|
|
||||||
# you'll get a folder 'goreleaser_Linux_arm64'.
|
|
||||||
# If set to false, all files are extracted separately.
|
|
||||||
# You can also set it to a custom folder name (templating is supported).
|
|
||||||
wrap_in_directory: true
|
|
||||||
|
|
||||||
# Strip parent folders when adding files to the archive.
|
# Strip parent folders when adding files to the archive.
|
||||||
strip_parent: true
|
strip_parent: true
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ WORKDIR /openim/openim-server
|
|||||||
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
COPY --from=builder /openim/openim-server/_output/bin/platforms /openim/openim-server/_output/bin/platforms
|
||||||
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
COPY --from=builder /openim/openim-server/config /openim/openim-server/config
|
||||||
|
|
||||||
ENV PORT 10140
|
ENV PORT 10140 \
|
||||||
ENV WS_PORT 10001
|
WS_PORT 10001 \
|
||||||
ENV CONFIG=/openim/openim-server/config
|
CONFIG=/openim/openim-server/config
|
||||||
|
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
EXPOSE $WS_PORT
|
EXPOSE $WS_PORT
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ require (
|
|||||||
require github.com/google/uuid v1.3.0
|
require github.com/google/uuid v1.3.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/OpenIMSDK/protocol v0.0.15
|
github.com/OpenIMSDK/protocol v0.0.17
|
||||||
github.com/OpenIMSDK/tools v0.0.14
|
github.com/OpenIMSDK/tools v0.0.14
|
||||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
||||||
github.com/go-redis/redis v6.15.9+incompatible
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
|
|||||||
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
||||||
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
|
github.com/OpenIMSDK/protocol v0.0.17 h1:ixjKUVGlTW+jQK5cPaKV//6l4bk9DAlbjDhocztYSbU=
|
||||||
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
|
github.com/OpenIMSDK/protocol v0.0.17/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||||
github.com/OpenIMSDK/protocol v0.0.15 h1:KrrvdHH9kFF/tFYL2FXRPAr2e5F5DctSHfHq6MQjUI4=
|
|
||||||
github.com/OpenIMSDK/protocol v0.0.15/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
|
||||||
github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
|
github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
|
||||||
github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||||
|
|||||||
@@ -22,12 +22,7 @@ import (
|
|||||||
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
relationtb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *groupServer) FindGroupMember(
|
func (s *groupServer) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
groupIDs []string,
|
|
||||||
userIDs []string,
|
|
||||||
roleLevels []int32,
|
|
||||||
) ([]*relationtb.GroupMemberModel, error) {
|
|
||||||
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
members, err := s.GroupDatabase.FindGroupMember(ctx, groupIDs, userIDs, roleLevels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -114,6 +114,24 @@ type groupServer struct {
|
|||||||
msgRpcClient rpcclient.MessageRpcClient
|
msgRpcClient rpcclient.MessageRpcClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *groupServer) NotificationUserInfoUpdate(ctx context.Context, req *pbgroup.NotificationUserInfoUpdateReq) (*pbgroup.NotificationUserInfoUpdateResp, error) {
|
||||||
|
defer log.ZDebug(ctx, "return")
|
||||||
|
|
||||||
|
members, err := s.GroupDatabase.FindGroupMember(ctx, nil, []string{req.UserID}, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, member := range members {
|
||||||
|
if member.Nickname != "" && member.FaceURL != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID); err != nil {
|
||||||
|
log.ZError(ctx, "setGroupMemberInfo notification failed", err, "member", member.UserID, "groupID", member.GroupID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &pbgroup.NotificationUserInfoUpdateResp{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
|
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
|
||||||
if !authverify.IsAppManagerUid(ctx) {
|
if !authverify.IsAppManagerUid(ctx) {
|
||||||
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
|
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ type userServer struct {
|
|||||||
friendNotificationSender *notification.FriendNotificationSender
|
friendNotificationSender *notification.FriendNotificationSender
|
||||||
userNotificationSender *notification.UserNotificationSender
|
userNotificationSender *notification.UserNotificationSender
|
||||||
friendRpcClient *rpcclient.FriendRpcClient
|
friendRpcClient *rpcclient.FriendRpcClient
|
||||||
|
groupRpcClient *rpcclient.GroupRpcClient
|
||||||
RegisterCenter registry.SvcDiscoveryRegistry
|
RegisterCenter registry.SvcDiscoveryRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,11 +82,13 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
|||||||
userMongoDB := unrelation.NewUserMongoDriver(mongo.GetDatabase())
|
userMongoDB := unrelation.NewUserMongoDriver(mongo.GetDatabase())
|
||||||
database := controller.NewUserDatabase(userDB, cache, tx.NewGorm(db), userMongoDB)
|
database := controller.NewUserDatabase(userDB, cache, tx.NewGorm(db), userMongoDB)
|
||||||
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
||||||
|
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||||
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
||||||
u := &userServer{
|
u := &userServer{
|
||||||
UserDatabase: database,
|
UserDatabase: database,
|
||||||
RegisterCenter: client,
|
RegisterCenter: client,
|
||||||
friendRpcClient: &friendRpcClient,
|
friendRpcClient: &friendRpcClient,
|
||||||
|
groupRpcClient: &groupRpcClient,
|
||||||
friendNotificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
|
friendNotificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
|
||||||
userNotificationSender: notification.NewUserNotificationSender(&msgRpcClient, notification.WithUserFunc(database.FindWithError)),
|
userNotificationSender: notification.NewUserNotificationSender(&msgRpcClient, notification.WithUserFunc(database.FindWithError)),
|
||||||
}
|
}
|
||||||
@@ -125,6 +128,11 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if req.UserInfo.Nickname != "" || req.UserInfo.FaceURL != "" {
|
||||||
|
if err := s.groupRpcClient.NotificationUserInfoUpdate(ctx, req.UserInfo.UserID); err != nil {
|
||||||
|
log.ZError(ctx, "NotificationUserInfoUpdate", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, friendID := range friends {
|
for _, friendID := range friends {
|
||||||
s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID)
|
s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,83 +41,34 @@ type GroupDatabase interface {
|
|||||||
TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
|
TakeGroup(ctx context.Context, groupID string) (group *relationtb.GroupModel, err error)
|
||||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
||||||
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
FindNotDismissedGroup(ctx context.Context, groupIDs []string) (groups []*relationtb.GroupModel, err error)
|
||||||
SearchGroup(
|
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupModel, error)
|
||||||
ctx context.Context,
|
|
||||||
keyword string,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (uint32, []*relationtb.GroupModel, error)
|
|
||||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||||
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
|
DismissGroup(ctx context.Context, groupID string, deleteMember bool) error // 解散群,并删除群成员
|
||||||
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error)
|
||||||
// GroupMember
|
// GroupMember
|
||||||
TakeGroupMember(
|
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationtb.GroupMemberModel, err error)
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userID string,
|
|
||||||
) (groupMember *relationtb.GroupMemberModel, err error)
|
|
||||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
|
TakeGroupOwner(ctx context.Context, groupID string) (*relationtb.GroupMemberModel, error)
|
||||||
FindGroupMember(
|
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationtb.GroupMemberModel, error)
|
||||||
ctx context.Context,
|
|
||||||
groupIDs []string,
|
|
||||||
userIDs []string,
|
|
||||||
roleLevels []int32,
|
|
||||||
) ([]*relationtb.GroupMemberModel, error)
|
|
||||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||||
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
||||||
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
||||||
PageGroupRequest(
|
PageGroupRequest(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupRequestModel, error)
|
||||||
ctx context.Context,
|
|
||||||
groupIDs []string,
|
PageGetJoinGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
||||||
pageNumber, showNumber int32,
|
PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
|
||||||
// PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber,
|
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationtb.GroupMemberModel) error
|
||||||
// showNumber int32) (uint32, []*relationtb.GroupMemberModel, error)
|
|
||||||
PageGetJoinGroup(
|
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
|
||||||
PageGetGroupMember(
|
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (total uint32, totalGroupMembers []*relationtb.GroupMemberModel, err error)
|
|
||||||
SearchGroupMember(
|
|
||||||
ctx context.Context,
|
|
||||||
keyword string,
|
|
||||||
groupIDs []string,
|
|
||||||
userIDs []string,
|
|
||||||
roleLevels []int32,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (uint32, []*relationtb.GroupMemberModel, error)
|
|
||||||
HandlerGroupRequest(
|
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userID string,
|
|
||||||
handledMsg string,
|
|
||||||
handleResult int32,
|
|
||||||
member *relationtb.GroupMemberModel,
|
|
||||||
) error
|
|
||||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
|
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error)
|
||||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||||
TransferGroupOwner(
|
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
oldOwnerUserID, newOwnerUserID string,
|
|
||||||
roleLevel int32,
|
|
||||||
) error // 转让群
|
|
||||||
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||||
UpdateGroupMembers(ctx context.Context, data []*relationtb.BatchUpdateGroupMember) error
|
UpdateGroupMembers(ctx context.Context, data []*relationtb.BatchUpdateGroupMember) error
|
||||||
// GroupRequest
|
// GroupRequest
|
||||||
CreateGroupRequest(ctx context.Context, requests []*relationtb.GroupRequestModel) error
|
CreateGroupRequest(ctx context.Context, requests []*relationtb.GroupRequestModel) error
|
||||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationtb.GroupRequestModel, error)
|
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationtb.GroupRequestModel, error)
|
||||||
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationtb.GroupRequestModel, error)
|
FindGroupRequests(ctx context.Context, groupID string, userIDs []string) (int64, []*relationtb.GroupRequestModel, error)
|
||||||
PageGroupRequestUser(
|
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationtb.GroupRequestModel, error)
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (uint32, []*relationtb.GroupRequestModel, error)
|
|
||||||
// SuperGroupModelInterface
|
// SuperGroupModelInterface
|
||||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationtb.SuperGroupModel, error)
|
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationtb.SuperGroupModel, error)
|
||||||
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
|
FindJoinSuperGroup(ctx context.Context, userID string) ([]string, error)
|
||||||
@@ -310,12 +261,22 @@ func (g *groupDatabase) PageGroupRequest(
|
|||||||
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
|
return g.groupRequestDB.PageGroup(ctx, groupIDs, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) FindGroupMember(
|
func (g *groupDatabase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
||||||
ctx context.Context,
|
if len(groupIDs) == 0 && len(roleLevels) == 0 && len(userIDs) == 1 {
|
||||||
groupIDs []string,
|
gIDs, err := g.cache.GetJoinedGroupIDs(ctx, userIDs[0])
|
||||||
userIDs []string,
|
if err != nil {
|
||||||
roleLevels []int32,
|
return nil, err
|
||||||
) (totalGroupMembers []*relationtb.GroupMemberModel, err error) {
|
}
|
||||||
|
var res []*relationtb.GroupMemberModel
|
||||||
|
for _, groupID := range gIDs {
|
||||||
|
v, err := g.cache.GetGroupMemberInfo(ctx, groupID, userIDs[0])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res = append(res, v)
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
if len(roleLevels) == 0 {
|
if len(roleLevels) == 0 {
|
||||||
for _, groupID := range groupIDs {
|
for _, groupID := range groupIDs {
|
||||||
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
|
groupMembers, err := g.cache.GetGroupMembersInfo(ctx, groupID, userIDs)
|
||||||
@@ -451,13 +412,8 @@ func (g *groupDatabase) MapGroupMemberNum(ctx context.Context, groupIDs []string
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) TransferGroupOwner(
|
func (g *groupDatabase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error {
|
||||||
ctx context.Context,
|
return g.tx.Transaction(func(tx any) error {
|
||||||
groupID string,
|
|
||||||
oldOwnerUserID, newOwnerUserID string,
|
|
||||||
roleLevel int32,
|
|
||||||
) error {
|
|
||||||
if err := g.tx.Transaction(func(tx any) error {
|
|
||||||
rowsAffected, err := g.groupMemberDB.NewTx(tx).UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel)
|
rowsAffected, err := g.groupMemberDB.NewTx(tx).UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -472,11 +428,8 @@ func (g *groupDatabase) TransferGroupOwner(
|
|||||||
if rowsAffected != 1 {
|
if rowsAffected != 1 {
|
||||||
return utils.Wrap(fmt.Errorf("newOwnerUserID %s rowsAffected = %d", newOwnerUserID, rowsAffected), "")
|
return utils.Wrap(fmt.Errorf("newOwnerUserID %s rowsAffected = %d", newOwnerUserID, rowsAffected), "")
|
||||||
}
|
}
|
||||||
return nil
|
return g.cache.DelGroupMembersInfo(groupID, oldOwnerUserID, newOwnerUserID).DelGroupMembersHash(groupID).ExecDel(ctx)
|
||||||
}); err != nil {
|
})
|
||||||
return err
|
|
||||||
}
|
|
||||||
return g.cache.DelGroupMembersInfo(groupID, oldOwnerUserID, newOwnerUserID).ExecDel(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) UpdateGroupMember(
|
func (g *groupDatabase) UpdateGroupMember(
|
||||||
|
|||||||
@@ -208,3 +208,10 @@ func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error
|
|||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GroupRpcClient) NotificationUserInfoUpdate(ctx context.Context, userID string) error {
|
||||||
|
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
|
||||||
|
UserID: userID,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
|
|||||||
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
})
|
})
|
||||||
return resp.GlobalRecvMsgOpt, err
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return resp.GlobalRecvMsgOpt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access verifies the access rights for the provided user ID.
|
// Access verifies the access rights for the provided user ID.
|
||||||
|
|||||||
Reference in New Issue
Block a user