From caf5b0d7c7f5df81613e7c80269cbe63a7515e49 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Wed, 14 Jun 2023 15:31:36 +0800 Subject: [PATCH 1/3] WsVerifyToken --- internal/rpc/user/user.go | 9 ++++----- pkg/rpcclient/notification/friend.go | 9 +++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 7f13c3aab..0d717cfd4 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -13,7 +13,6 @@ import ( "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/relation" tablerelation "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/tx" - "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify" registry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry" "github.com/OpenIMSDK/Open-IM-Server/pkg/errs" @@ -94,14 +93,14 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI if err != nil { return nil, err } + _ = s.notificationSender.UserInfoUpdatedNotification(ctx, req.UserInfo.UserID) friends, err := s.friendRpcClient.GetFriendIDs(ctx, req.UserInfo.UserID) if err != nil { return nil, err } - for _, v := range friends { - s.notificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, v, mcontext.GetOpUserID(ctx)) + for _, friendID := range friends { + s.notificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID) } - s.notificationSender.UserInfoUpdatedNotification(ctx, mcontext.GetOpUserID(ctx), req.UserInfo.UserID) return resp, nil } @@ -116,7 +115,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se if err := s.UpdateByMap(ctx, req.UserID, m); err != nil { return nil, err } - s.notificationSender.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID) + s.notificationSender.UserInfoUpdatedNotification(ctx, req.UserID) return resp, nil } diff --git a/pkg/rpcclient/notification/friend.go b/pkg/rpcclient/notification/friend.go index 7c655686d..803c748c0 100644 --- a/pkg/rpcclient/notification/friend.go +++ b/pkg/rpcclient/notification/friend.go @@ -2,6 +2,7 @@ package notification import ( "context" + "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert" @@ -91,9 +92,9 @@ func (f *FriendNotificationSender) getFromToUserNickname(ctx context.Context, fr return users[fromUserID].Nickname, users[toUserID].Nickname, nil } -func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, opUserID string, changedUserID string) error { +func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, changedUserID string) error { tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - return f.Notification(ctx, opUserID, changedUserID, constant.UserInfoUpdatedNotification, &tips) + return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips) } func (f *FriendNotificationSender) FriendApplicationAddNotification(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) error { @@ -171,7 +172,7 @@ func (c *FriendNotificationSender) BlackDeletedNotification(ctx context.Context, c.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips) } -func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string, opUserID string) { +func (c *FriendNotificationSender) FriendInfoUpdatedNotification(ctx context.Context, changedUserID string, needNotifiedUserID string) { tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID} - c.Notification(ctx, opUserID, needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips) + c.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips) } From e7f76f44def40c85f8e501d8582f8147fc7753e3 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 14 Jun 2023 15:32:22 +0800 Subject: [PATCH 2/3] fix: friend add create time --- pkg/common/db/controller/friend.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index 1c3fc0364..90985c9ad 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -81,6 +81,7 @@ func (f *friendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUse m["handle_msg"] = "" m["req_msg"] = reqMsg m["ex"] = ex + m["create_time"] = time.Now() if err := f.friendRequest.NewTx(tx).UpdateByMap(ctx, fromUserID, toUserID, m); err != nil { return err } From 230513d61b7f31094368d3dea9bd808d318238f0 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Wed, 14 Jun 2023 16:30:56 +0800 Subject: [PATCH 3/3] fix: msg rpc panic --- internal/rpc/msg/as_read.go | 2 +- internal/rpc/msg/server.go | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/rpc/msg/as_read.go b/internal/rpc/msg/as_read.go index 19c97fb19..8bca14c7f 100644 --- a/internal/rpc/msg/as_read.go +++ b/internal/rpc/msg/as_read.go @@ -35,7 +35,7 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m return resp, nil } -func (m *msgServer) SetConversationHasReadMaxSeq(ctx context.Context, req *msg.SetConversationHasReadSeqReq) (resp *msg.SetConversationHasReadSeqResp, err error) { +func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetConversationHasReadSeqReq) (resp *msg.SetConversationHasReadSeqResp, err error) { maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID) if err != nil { return diff --git a/internal/rpc/msg/server.go b/internal/rpc/msg/server.go index 94510771c..c2b30191e 100644 --- a/internal/rpc/msg/server.go +++ b/internal/rpc/msg/server.go @@ -34,11 +34,6 @@ type msgServer struct { notificationSender *rpcclient.NotificationSender } -func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetConversationHasReadSeqReq) (*msg.SetConversationHasReadSeqResp, error) { - //TODO implement me - panic("implement me") -} - func (m *msgServer) addInterceptorHandler(interceptorFunc ...MessageInterceptorFunc) { m.Handlers = append(m.Handlers, interceptorFunc...) }