mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 10:05:58 +08:00
add crud for general function user process, add pinFriend (#1532)
* update set pin friends * update set pin friends * update set pin friends * update set pin friends * update set pin friends * update set pin friends * fix bugs * fix bugs * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * debug * Update go.mod * Update friend.go * debug * debug * debug * add pin friend test * add pin friend test * add pin friend test * add pin friend test * add pin friend test * add pin friend test * add pin friend test * add pin friend test * add pin friend test * I cannot solve todo in test.sh * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * update user command * Update go.mod * fix group notification * fix group notification * update openimsdk tools * update openim server remove duplicate code * update openim server remove duplicate code * update user command get * update user command get * update response of callback response error * update black ex * update join group ex * update user pb2map * update go sum * update go sum --------- Co-authored-by: Xinwei Xiong <3293172751@qq.com>
This commit is contained in:
@@ -79,6 +79,7 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbfriend.AddBlackReq)
|
||||
BlockUserID: req.BlackUserID,
|
||||
OperatorUserID: mcontext.GetOpUserID(ctx),
|
||||
CreateTime: time.Now(),
|
||||
Ex: req.Ex,
|
||||
}
|
||||
if err := s.blackDatabase.Create(ctx, []*relation.BlackModel{&black}); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -53,10 +53,6 @@ type friendServer struct {
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (s *friendServer) PinFriends(ctx context.Context, req *pbfriend.PinFriendsReq) (*pbfriend.PinFriendsResp, error) {
|
||||
return nil, errs.ErrInternalServer.Wrap("not implemented")
|
||||
}
|
||||
|
||||
func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
// Initialize MongoDB
|
||||
mongo, err := unrelation.NewMongo()
|
||||
@@ -411,6 +407,7 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
|
||||
}
|
||||
var friendInfo *sdkws.FriendInfo
|
||||
if friend := friendMap[userID]; friend != nil {
|
||||
|
||||
friendInfo = &sdkws.FriendInfo{
|
||||
OwnerUserID: friend.OwnerUserID,
|
||||
Remark: friend.Remark,
|
||||
@@ -418,6 +415,7 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
|
||||
AddSource: friend.AddSource,
|
||||
OperatorUserID: friend.OperatorUserID,
|
||||
Ex: friend.Ex,
|
||||
IsPinned: friend.IsPinned,
|
||||
}
|
||||
}
|
||||
var blackInfo *sdkws.BlackInfo
|
||||
@@ -438,3 +436,35 @@ func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfrien
|
||||
}
|
||||
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")
|
||||
}
|
||||
var isPinned bool
|
||||
if req.IsPinned != nil {
|
||||
isPinned = req.IsPinned.Value
|
||||
} else {
|
||||
return nil, errs.ErrArgs.Wrap("isPinned is nil")
|
||||
}
|
||||
//check whther in friend list
|
||||
_, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//set friendslist friend pin status to isPinned
|
||||
for _, friendID := range req.FriendUserIDs {
|
||||
if err := s.friendDatabase.UpdateFriendPinStatus(ctx, req.OwnerUserID, friendID, isPinned); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resp := &pbfriend.PinFriendsResp{}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -327,8 +327,6 @@ func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserT
|
||||
// Handle the scenario where certain members are refused
|
||||
// You might want to update the req.Members list or handle it as per your business logic
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -395,7 +393,10 @@ func CallbackBeforeSetGroupInfo(ctx context.Context, req *group.SetGroupInfoReq)
|
||||
if resp.ApplyMemberFriend != nil {
|
||||
req.GroupInfoForSet.ApplyMemberFriend = wrapperspb.Int32(*resp.ApplyMemberFriend)
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
utils.NotNilReplace(&req.GroupInfoForSet.GroupID, &resp.GroupID)
|
||||
utils.NotNilReplace(&req.GroupInfoForSet.GroupName, &resp.GroupName)
|
||||
utils.NotNilReplace(&req.GroupInfoForSet.FaceURL, &resp.FaceURL)
|
||||
utils.NotNilReplace(&req.GroupInfoForSet.Introduction, &resp.Introduction)
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterSetGroupInfo(ctx context.Context, req *group.SetGroupInfoReq) error {
|
||||
@@ -426,6 +427,5 @@ func CallbackAfterSetGroupInfo(ctx context.Context, req *group.SetGroupInfoReq)
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterSetGroupInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -802,6 +802,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
||||
GroupType: string(group.GroupType),
|
||||
ApplyID: req.InviterUserID,
|
||||
ReqMessage: req.ReqMessage,
|
||||
Ex: req.Ex,
|
||||
}
|
||||
|
||||
if err = CallbackApplyJoinGroupBefore(ctx, reqCall); err != nil {
|
||||
@@ -848,6 +849,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbgroup.JoinGroupReq)
|
||||
JoinSource: req.JoinSource,
|
||||
ReqTime: time.Now(),
|
||||
HandledTime: time.Unix(0, 0),
|
||||
Ex: req.Ex,
|
||||
}
|
||||
if err := s.db.CreateGroupRequest(ctx, []*relationtb.GroupRequestModel{&groupRequest}); err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -202,6 +202,5 @@ func CallbackAfterRevokeMsg(ctx context.Context, req *pbchat.RevokeMsgReq) error
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterRevokeMsg); err != nil {
|
||||
return err
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -101,6 +101,16 @@ type thirdServer struct {
|
||||
defaultExpire time.Duration
|
||||
}
|
||||
|
||||
func (t *thirdServer) InitiateFormData(ctx context.Context, req *third.InitiateFormDataReq) (*third.InitiateFormDataResp, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (t *thirdServer) CompleteFormData(ctx context.Context, req *third.CompleteFormDataReq) (*third.CompleteFormDataResp, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
|
||||
err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime)
|
||||
if err != nil {
|
||||
|
||||
+56
-16
@@ -56,22 +56,6 @@ type userServer struct {
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
}
|
||||
|
||||
func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.ProcessUserCommandAddReq) (*pbuser.ProcessUserCommandAddResp, error) {
|
||||
return nil, errs.ErrInternalServer.Wrap("not implemented")
|
||||
}
|
||||
|
||||
func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.ProcessUserCommandUpdateReq) (*pbuser.ProcessUserCommandUpdateResp, error) {
|
||||
return nil, errs.ErrInternalServer.Wrap("not implemented")
|
||||
}
|
||||
|
||||
func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.ProcessUserCommandDeleteReq) (*pbuser.ProcessUserCommandDeleteResp, error) {
|
||||
return nil, errs.ErrInternalServer.Wrap("not implemented")
|
||||
}
|
||||
|
||||
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
|
||||
return nil, errs.ErrInternalServer.Wrap("not implemented")
|
||||
}
|
||||
|
||||
func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
rdb, err := cache.NewRedis()
|
||||
if err != nil {
|
||||
@@ -350,3 +334,59 @@ func (s *userServer) GetSubscribeUsersStatus(ctx context.Context,
|
||||
}
|
||||
return &pbuser.GetSubscribeUsersStatusResp{StatusList: onlineStatusList}, nil
|
||||
}
|
||||
|
||||
// ProcessUserCommandAdd user general function add
|
||||
func (s *userServer) ProcessUserCommandAdd(ctx context.Context, req *pbuser.ProcessUserCommandAddReq) (*pbuser.ProcessUserCommandAddResp, error) {
|
||||
// Assuming you have a method in s.UserDatabase to add a user command
|
||||
err := s.UserDatabase.AddUserCommand(ctx, req.UserID, req.Type, req.Uuid, req.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pbuser.ProcessUserCommandAddResp{}, nil
|
||||
}
|
||||
|
||||
// ProcessUserCommandDelete user general function delete
|
||||
func (s *userServer) ProcessUserCommandDelete(ctx context.Context, req *pbuser.ProcessUserCommandDeleteReq) (*pbuser.ProcessUserCommandDeleteResp, error) {
|
||||
// Assuming you have a method in s.UserDatabase to delete a user command
|
||||
err := s.UserDatabase.DeleteUserCommand(ctx, req.UserID, req.Type, req.Uuid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pbuser.ProcessUserCommandDeleteResp{}, nil
|
||||
}
|
||||
|
||||
// ProcessUserCommandUpdate user general function update
|
||||
func (s *userServer) ProcessUserCommandUpdate(ctx context.Context, req *pbuser.ProcessUserCommandUpdateReq) (*pbuser.ProcessUserCommandUpdateResp, error) {
|
||||
// Assuming you have a method in s.UserDatabase to update a user command
|
||||
err := s.UserDatabase.UpdateUserCommand(ctx, req.UserID, req.Type, req.Uuid, req.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pbuser.ProcessUserCommandUpdateResp{}, nil
|
||||
}
|
||||
|
||||
func (s *userServer) ProcessUserCommandGet(ctx context.Context, req *pbuser.ProcessUserCommandGetReq) (*pbuser.ProcessUserCommandGetResp, error) {
|
||||
// Fetch user commands from the database
|
||||
commands, err := s.UserDatabase.GetUserCommands(ctx, req.UserID, req.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Initialize commandInfoSlice as an empty slice
|
||||
commandInfoSlice := make([]*pbuser.CommandInfoResp, 0, len(commands))
|
||||
|
||||
for _, command := range commands {
|
||||
// No need to use index since command is already a pointer
|
||||
commandInfoSlice = append(commandInfoSlice, &pbuser.CommandInfoResp{
|
||||
Uuid: command.Uuid,
|
||||
Value: command.Value,
|
||||
CreateTime: command.CreateTime,
|
||||
})
|
||||
}
|
||||
|
||||
// Return the response with the slice
|
||||
return &pbuser.ProcessUserCommandGetResp{KVArray: commandInfoSlice}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user