From d346fcb4d67dc29c0dadf687ee839927832ade46 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Fri, 1 May 2026 02:27:52 +0800 Subject: [PATCH 01/10] first name --- internal/rpc/relation/friend.go | 20 ++++++++++++-------- pkg/common/convert/friend.go | 11 +++++++++-- protocol | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index ef44566f2..a1c2d24cd 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -314,7 +314,11 @@ func (s *friendServer) GetFriendInfo(ctx context.Context, req *relation.GetFrien if err != nil { return nil, err } - return &relation.GetFriendInfoResp{FriendInfos: convert.FriendOnlyDB2PbOnly(friends)}, nil + users, err := s.userClient.GetUsersInfoMap(ctx, req.FriendUserIDs) + if err != nil { + return nil, err + } + return &relation.GetFriendInfoResp{FriendInfos: convert.FriendOnlyDB2PbOnly(friends, users)}, nil } func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *relation.GetDesignatedFriendsReq) (resp *relation.GetDesignatedFriendsResp, err error) { @@ -698,13 +702,13 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT } // Notify only A (FromUserID) so incremental friend sync is triggered // without notifying B (ToUserID). - tips := sdkws.FriendApplicationApprovedTips{ - FromToUserID: &sdkws.FromToUserID{ - FromUserID: req.FromUserID, - ToUserID: req.ToUserID, - }, - } - s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) + //tips := sdkws.FriendApplicationApprovedTips{ + // FromToUserID: &sdkws.FromToUserID{ + // FromUserID: req.FromUserID, + // ToUserID: req.ToUserID, + // }, + //} + //s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) return &relation.ApplyToAddFriendResp{}, nil } diff --git a/pkg/common/convert/friend.go b/pkg/common/convert/friend.go index 994c6d7d5..e530edca2 100644 --- a/pkg/common/convert/friend.go +++ b/pkg/common/convert/friend.go @@ -78,6 +78,8 @@ func FriendsDB2Pb(ctx context.Context, friendsDB []*model.Friend, getUsers func( friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL friendPb.FriendUser.Ex = users[friend.FriendUserID].Ex + friendPb.FriendUser.FirstName = users[friend.FriendUserID].FirstName + friendPb.FriendUser.LastName = users[friend.FriendUserID].LastName friendPb.CreateTime = friend.CreateTime.Unix() friendPb.IsPinned = friend.IsPinned friendPb.IsMute = friend.IsMuted @@ -88,9 +90,9 @@ func FriendsDB2Pb(ctx context.Context, friendsDB []*model.Friend, getUsers func( return friendsPb, nil } -func FriendOnlyDB2PbOnly(friendsDB []*model.Friend) []*relation.FriendInfoOnly { +func FriendOnlyDB2PbOnly(friendsDB []*model.Friend, users map[string]*sdkws.UserInfo) []*relation.FriendInfoOnly { return datautil.Slice(friendsDB, func(f *model.Friend) *relation.FriendInfoOnly { - return &relation.FriendInfoOnly{ + info := &relation.FriendInfoOnly{ OwnerUserID: f.OwnerUserID, FriendUserID: f.FriendUserID, Remark: f.Remark, @@ -103,6 +105,11 @@ func FriendOnlyDB2PbOnly(friendsDB []*model.Friend) []*relation.FriendInfoOnly { MuteDuration: f.MuteDuration, MuteEndTime: f.MuteEndTime, } + if u, ok := users[f.FriendUserID]; ok { + info.FirstName = u.FirstName + info.LastName = u.LastName + } + return info }) } diff --git a/protocol b/protocol index 7f613eb71..0db6a7324 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 7f613eb71f23a69730cfb3c3abd1515da0fb17cf +Subproject commit 0db6a732426df40792921f861112e32785405e8d From 8c442c2e244f2069d1ea891c5b49c441fec03f68 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Sun, 3 May 2026 14:47:47 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=80=9A=E7=9F=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/relation/friend.go | 14 +++++--------- internal/rpc/relation/notification.go | 13 +++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index a1c2d24cd..3c3c844e0 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -700,15 +700,11 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT if err := s.db.BecomeOnewayFriend(ctx, req.FromUserID, req.ToUserID, becomeFriendByOneway, req.Remark); err != nil { return nil, err } - // Notify only A (FromUserID) so incremental friend sync is triggered - // without notifying B (ToUserID). - //tips := sdkws.FriendApplicationApprovedTips{ - // FromToUserID: &sdkws.FromToUserID{ - // FromUserID: req.FromUserID, - // ToUserID: req.ToUserID, - // }, - //} - //s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) + + // Silently notify only A (FromUserID) to trigger an incremental friend-list sync + // so the remark is reflected in the conversation list. + // B (ToUserID) receives no notification of any kind. + s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) return &relation.ApplyToAddFriendResp{}, nil } diff --git a/internal/rpc/relation/notification.go b/internal/rpc/relation/notification.go index 4ee45e197..d9d773c76 100644 --- a/internal/rpc/relation/notification.go +++ b/internal/rpc/relation/notification.go @@ -282,6 +282,19 @@ func (f *FriendNotificationSender) FriendsInfoUpdateNotification(ctx context.Con f.Notification(ctx, toUserID, toUserID, constant.FriendsInfoUpdateNotification, &tips) } +// FriendAddedOnewayNotification silently notifies ownerUserID that friendUserID has been added +// to their friend list (one-way, no consent from friendUserID required). +// isSendMsg=false ensures no visible message appears in either user's conversation list. +func (f *FriendNotificationSender) FriendAddedOnewayNotification(ctx context.Context, ownerUserID, friendUserID string) { + tips := sdkws.FriendsInfoUpdateTips{ + FromToUserID: &sdkws.FromToUserID{ToUserID: ownerUserID}, + FriendIDs: []string{friendUserID}, + } + f.setSortVersion(ctx, &tips.FriendVersion, &tips.FriendVersionID, + database.FriendVersionName, ownerUserID, &tips.FriendSortVersion) + f.Notification(ctx, ownerUserID, ownerUserID, constant.FriendsInfoUpdateNotification, &tips) +} + func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, req *relation.AddBlackReq) { tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}} tips.FromToUserID.FromUserID = req.OwnerUserID From c0076e12024b66ff0e81f7dc18a25b21d2be9c00 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Sun, 3 May 2026 17:25:42 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=80=9A=E7=9F=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/relation/friend.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index 3c3c844e0..861ae1ecd 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -704,7 +704,17 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT // Silently notify only A (FromUserID) to trigger an incremental friend-list sync // so the remark is reflected in the conversation list. // B (ToUserID) receives no notification of any kind. - s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) + //s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) + + // Notify only A (FromUserID) so incremental friend sync is triggered + // without notifying B (ToUserID). + tips := sdkws.FriendApplicationApprovedTips{ + FromToUserID: &sdkws.FromToUserID{ + FromUserID: req.FromUserID, + ToUserID: req.ToUserID, + }, + } + s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) return &relation.ApplyToAddFriendResp{}, nil } From 5118bcc1c097c90b89a5199c8b48bbf59c2c0afc Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Sun, 3 May 2026 22:05:57 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A5=BD=E5=8F=8B?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=80=9A=E7=9F=A5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/router.go | 1 + internal/rpc/relation/friend.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/api/router.go b/internal/api/router.go index accaae666..11caa06b9 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -205,6 +205,7 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, co friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs) friendRouterGroup.POST("/get_self_unhandled_apply_count", f.GetSelfUnhandledApplyCount) friendRouterGroup.POST("/get_pinned_friend_ids", f.GetPinnedFriendIDs) + friendRouterGroup.POST("/add_oneway_friend", f.AddOnewayFriend) } g := NewGroupApi(group.NewGroupClient(groupConn)) diff --git a/internal/rpc/relation/friend.go b/internal/rpc/relation/friend.go index 861ae1ecd..770158882 100644 --- a/internal/rpc/relation/friend.go +++ b/internal/rpc/relation/friend.go @@ -704,17 +704,17 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT // Silently notify only A (FromUserID) to trigger an incremental friend-list sync // so the remark is reflected in the conversation list. // B (ToUserID) receives no notification of any kind. - //s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) + s.notificationSender.FriendAddedOnewayNotification(ctx, req.FromUserID, req.ToUserID) // Notify only A (FromUserID) so incremental friend sync is triggered // without notifying B (ToUserID). - tips := sdkws.FriendApplicationApprovedTips{ - FromToUserID: &sdkws.FromToUserID{ - FromUserID: req.FromUserID, - ToUserID: req.ToUserID, - }, - } - s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) + //tips := sdkws.FriendApplicationApprovedTips{ + // FromToUserID: &sdkws.FromToUserID{ + // FromUserID: req.FromUserID, + // ToUserID: req.ToUserID, + // }, + //} + //s.notificationSender.Notification(ctx, req.FromUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips) return &relation.ApplyToAddFriendResp{}, nil } From f9250283c1af3da5d2aa6341a0e71863254650a1 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 16:11:26 +0800 Subject: [PATCH 05/10] update user fisrtname and lastname --- pkg/common/convert/user.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go index 4cf094c24..8305f56c8 100644 --- a/pkg/common/convert/user.go +++ b/pkg/common/convert/user.go @@ -115,6 +115,23 @@ func UserPb2DBMapEx(user *sdkws.UserInfoWithEx) map[string]any { if user.Ex != nil { val["ex"] = user.Ex.Value } + if user.FirstName != nil { + val["first_name"] = user.FirstName.Value + } + if user.LastName != nil { + val["last_name"] = user.LastName.Value + } + if user.FirstName != nil || user.LastName != nil { + firstName := "" + lastName := "" + if user.FirstName != nil { + firstName = user.FirstName.Value + } + if user.LastName != nil { + lastName = user.LastName.Value + } + val["full_name"] = BuildFullName(firstName, lastName) + } if user.GlobalRecvMsgOpt != nil { val["global_recv_msg_opt"] = user.GlobalRecvMsgOpt.Value } @@ -130,7 +147,5 @@ func UserPb2DBMapEx(user *sdkws.UserInfoWithEx) map[string]any { if user.MsgReceiveSetting != nil { val["msg_receive_setting"] = user.MsgReceiveSetting.Value } - // TODO: Add FirstName/LastName support to UserInfoWithEx proto when regenerated - return val } From 1444496c9d4e48dca03c2ea4eeb7c5ed9f729571 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 17:33:14 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=9D=A5=E7=94=B5=E9=93=83=E5=A3=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/rpc/rtc/signal.go | 40 +++++++++++++++++++++++++++----- pkg/common/convert/user.go | 24 ++++++++++++------- pkg/common/storage/model/user.go | 2 ++ protocol | 2 +- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/internal/rpc/rtc/signal.go b/internal/rpc/rtc/signal.go index b20e02d36..393f1f2bc 100644 --- a/internal/rpc/rtc/signal.go +++ b/internal/rpc/rtc/signal.go @@ -108,6 +108,19 @@ func (s *rtcServer) handleInvite(ctx context.Context, req *rtc.SignalInviteReq, } } + // 从主叫用户资料获取铃声 URL,注入到邀请信息中,被叫方收到后播放主叫方铃声 + if inviterInfo, err := s.userClient.GetUserInfo(ctx, req.UserID); err == nil && inviterInfo.CallRingtoneURL != "" { + inv.CallerRingtoneURL = inviterInfo.CallRingtoneURL + } + + // 查询被叫方铃声 URL,供主叫方在等待时播放 + var calleeRingtoneURL string + if len(inv.InviteeUserIDList) > 0 { + if inviteeInfo, err := s.userClient.GetUserInfo(ctx, inv.InviteeUserIDList[0]); err == nil { + calleeRingtoneURL = inviteeInfo.CallRingtoneURL + } + } + if _, err := s.roomClient.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: inv.RoomID}); err != nil { log.ZError(ctx, "handleInvite", err, "r", err.Error()) return nil, errs.WrapMsg(err, "LiveKit CreateRoom failed", "roomID", inv.RoomID) @@ -147,9 +160,10 @@ func (s *rtcServer) handleInvite(ctx context.Context, req *rtc.SignalInviteReq, log.ZDebug(ctx, "handleInvite", "token", token, "roomID", inv.RoomID, "liveURL", s.config.RpcConfig.LiveKit.ExternalAddress) return &rtc.SignalInviteResp{ - Token: token, - RoomID: inv.RoomID, - LiveURL: s.config.RpcConfig.LiveKit.ExternalAddress, + Token: token, + RoomID: inv.RoomID, + LiveURL: s.config.RpcConfig.LiveKit.ExternalAddress, + CalleeRingtoneURL: calleeRingtoneURL, }, nil } @@ -164,6 +178,19 @@ func (s *rtcServer) handleInviteInGroup(ctx context.Context, req *rtc.SignalInvi inv.InviterUserID = req.UserID inv.InitiateTime = time.Now().UnixMilli() + // 从主叫用户资料获取铃声 URL,注入到邀请信息中,被叫方收到后播放主叫方铃声 + if inviterInfo, err := s.userClient.GetUserInfo(ctx, req.UserID); err == nil && inviterInfo.CallRingtoneURL != "" { + inv.CallerRingtoneURL = inviterInfo.CallRingtoneURL + } + + // 查询第一位被叫的铃声 URL,供主叫方在等待时播放 + var calleeRingtoneURL string + if len(inv.InviteeUserIDList) > 0 { + if inviteeInfo, err := s.userClient.GetUserInfo(ctx, inv.InviteeUserIDList[0]); err == nil { + calleeRingtoneURL = inviteeInfo.CallRingtoneURL + } + } + if _, err := s.roomClient.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: inv.RoomID}); err != nil { return nil, errs.WrapMsg(err, "LiveKit CreateRoom failed", "roomID", inv.RoomID) } @@ -206,9 +233,10 @@ func (s *rtcServer) handleInviteInGroup(ctx context.Context, req *rtc.SignalInvi } return &rtc.SignalInviteInGroupResp{ - Token: token, - RoomID: inv.RoomID, - LiveURL: s.config.RpcConfig.LiveKit.ExternalAddress, + Token: token, + RoomID: inv.RoomID, + LiveURL: s.config.RpcConfig.LiveKit.ExternalAddress, + CalleeRingtoneURL: calleeRingtoneURL, }, nil } diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go index 8305f56c8..b49c7b7c5 100644 --- a/pkg/common/convert/user.go +++ b/pkg/common/convert/user.go @@ -49,6 +49,7 @@ func UserDB2Pb(user *relationtb.User) *sdkws.UserInfo { PhoneVisibility: user.PhoneVisibility, CallAcceptSetting: user.CallAcceptSetting, MsgReceiveSetting: user.MsgReceiveSetting, + CallRingtoneURL: user.CallRingtoneURL, } } @@ -59,16 +60,17 @@ func UsersDB2Pb(users []*relationtb.User) []*sdkws.UserInfo { func UserPb2DB(user *sdkws.UserInfo) *relationtb.User { fullName := BuildFullName(user.FirstName, user.LastName) return &relationtb.User{ - UserID: user.UserID, - Nickname: user.Nickname, - FaceURL: user.FaceURL, - Ex: user.Ex, - CreateTime: time.UnixMilli(user.CreateTime), - AppMangerLevel: user.AppMangerLevel, + UserID: user.UserID, + Nickname: user.Nickname, + FaceURL: user.FaceURL, + Ex: user.Ex, + CreateTime: time.UnixMilli(user.CreateTime), + AppMangerLevel: user.AppMangerLevel, GlobalRecvMsgOpt: user.GlobalRecvMsgOpt, - FirstName: user.FirstName, - LastName: user.LastName, - FullName: fullName, + FirstName: user.FirstName, + LastName: user.LastName, + FullName: fullName, + CallRingtoneURL: user.CallRingtoneURL, } } @@ -85,6 +87,7 @@ func UserPb2DBMap(user *sdkws.UserInfo) map[string]any { "last_name": user.LastName, "app_manager_level": user.AppMangerLevel, "global_recv_msg_opt": user.GlobalRecvMsgOpt, + "call_ringtone_url": user.CallRingtoneURL, } for key, value := range fields { if v, ok := value.(string); ok && v != "" { @@ -147,5 +150,8 @@ func UserPb2DBMapEx(user *sdkws.UserInfoWithEx) map[string]any { if user.MsgReceiveSetting != nil { val["msg_receive_setting"] = user.MsgReceiveSetting.Value } + if user.CallRingtoneURL != nil { + val["call_ringtone_url"] = user.CallRingtoneURL.Value + } return val } diff --git a/pkg/common/storage/model/user.go b/pkg/common/storage/model/user.go index 8c2e18167..fa6786947 100644 --- a/pkg/common/storage/model/user.go +++ b/pkg/common/storage/model/user.go @@ -57,6 +57,8 @@ type User struct { PhoneVisibility int32 `bson:"phone_visibility"` CallAcceptSetting int32 `bson:"call_accept_setting"` MsgReceiveSetting int32 `bson:"msg_receive_setting"` + // CallRingtoneURL 用户自定义来电铃声 URL;对方来电时播放此铃声 + CallRingtoneURL string `bson:"call_ringtone_url"` } func (u *User) GetNickname() string { diff --git a/protocol b/protocol index 0db6a7324..8bdb641d1 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 0db6a732426df40792921f861112e32785405e8d +Subproject commit 8bdb641d1356efc61620c0d37647a86f5dc94973 From a305b7f8624bfd39fff57a293b37175ac6091f7d Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 20:27:11 +0800 Subject: [PATCH 07/10] update user fisrtname and lastname --- pkg/common/storage/database/mgo/user.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/common/storage/database/mgo/user.go b/pkg/common/storage/database/mgo/user.go index 5a2dc7e34..ef599b782 100644 --- a/pkg/common/storage/database/mgo/user.go +++ b/pkg/common/storage/database/mgo/user.go @@ -63,7 +63,15 @@ func (u *UserMgo) UpdateByMap(ctx context.Context, userID string, args map[strin if len(args) == 0 { return nil } - return mongoutil.UpdateOne(ctx, u.coll, bson.M{"user_id": userID}, bson.M{"$set": args}, true) + filter := bson.M{"user_id": userID} + update := bson.M{"$set": args} + if err := mongoutil.UpdateOne(ctx, u.coll, filter, update, true); err != nil { + return err + } + + // Keep user attributes in sync for consumers that read from the "attribute" collection. + attributeColl := u.coll.Database().Collection("attribute") + return mongoutil.UpdateOne(ctx, attributeColl, filter, update, true) } func (u *UserMgo) Find(ctx context.Context, userIDs []string) (users []*model.User, err error) { From 64cc500c0dc55f0827d7b01c1aff525e5e02a911 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 20:35:09 +0800 Subject: [PATCH 08/10] update user fisrtname and lastname --- pkg/common/storage/database/mgo/user.go | 33 ++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/pkg/common/storage/database/mgo/user.go b/pkg/common/storage/database/mgo/user.go index ef599b782..15f86fd07 100644 --- a/pkg/common/storage/database/mgo/user.go +++ b/pkg/common/storage/database/mgo/user.go @@ -16,9 +16,10 @@ package mgo import ( "context" + "time" + "github.com/openimsdk/open-im-server/v3/pkg/common/storage/database" "github.com/openimsdk/open-im-server/v3/pkg/common/storage/model" - "time" "github.com/openimsdk/protocol/user" "github.com/openimsdk/tools/db/mongoutil" @@ -69,9 +70,35 @@ func (u *UserMgo) UpdateByMap(ctx context.Context, userID string, args map[strin return err } + return nil + // Keep user attributes in sync for consumers that read from the "attribute" collection. - attributeColl := u.coll.Database().Collection("attribute") - return mongoutil.UpdateOne(ctx, attributeColl, filter, update, true) + // Only sync the allowed attribute fields. + //attributeSet := make(map[string]any) + //for _, key := range []string{ + // "nickname", + // "first_name", + // "last_name", + // "full_name", + // "remark", + // "face_url", + // "phone_number", + // "area_code", + //} { + // if v, ok := args[key]; ok { + // attributeSet[key] = v + // } + //} + //// user collection uses "phone"; attribute collection uses "phone_number". + //if v, ok := args["phone"]; ok { + // attributeSet["phone_number"] = v + //} + //if len(attributeSet) == 0 { + // return nil + //} + + //attributeColl := u.coll.Database().Collection("attribute") + //return mongoutil.UpdateOne(ctx, attributeColl, filter, bson.M{"$set": attributeSet}, true) } func (u *UserMgo) Find(ctx context.Context, userIDs []string) (users []*model.User, err error) { From ae00605f22ecf3318059a0022f4cc62fb1a6d06f Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 20:56:35 +0800 Subject: [PATCH 09/10] update area_code --- pkg/common/convert/user.go | 6 ++++++ pkg/common/storage/model/user.go | 1 + protocol | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/common/convert/user.go b/pkg/common/convert/user.go index b49c7b7c5..2c4063cbf 100644 --- a/pkg/common/convert/user.go +++ b/pkg/common/convert/user.go @@ -46,6 +46,7 @@ func UserDB2Pb(user *relationtb.User) *sdkws.UserInfo { FirstName: user.FirstName, LastName: user.LastName, Phone: user.Phone, + AreaCode: user.AreaCode, PhoneVisibility: user.PhoneVisibility, CallAcceptSetting: user.CallAcceptSetting, MsgReceiveSetting: user.MsgReceiveSetting, @@ -70,6 +71,7 @@ func UserPb2DB(user *sdkws.UserInfo) *relationtb.User { FirstName: user.FirstName, LastName: user.LastName, FullName: fullName, + AreaCode: user.AreaCode, CallRingtoneURL: user.CallRingtoneURL, } } @@ -85,6 +87,7 @@ func UserPb2DBMap(user *sdkws.UserInfo) map[string]any { "ex": user.Ex, "first_name": user.FirstName, "last_name": user.LastName, + "area_code": user.AreaCode, "app_manager_level": user.AppMangerLevel, "global_recv_msg_opt": user.GlobalRecvMsgOpt, "call_ringtone_url": user.CallRingtoneURL, @@ -141,6 +144,9 @@ func UserPb2DBMapEx(user *sdkws.UserInfoWithEx) map[string]any { if user.Phone != nil { val["phone"] = user.Phone.Value } + if user.AreaCode != nil { + val["area_code"] = user.AreaCode.Value + } if user.PhoneVisibility != nil { val["phone_visibility"] = user.PhoneVisibility.Value } diff --git a/pkg/common/storage/model/user.go b/pkg/common/storage/model/user.go index fa6786947..14f026fac 100644 --- a/pkg/common/storage/model/user.go +++ b/pkg/common/storage/model/user.go @@ -54,6 +54,7 @@ type User struct { LastName string `bson:"last_name"` FullName string `bson:"full_name"` Phone string `bson:"phone"` + AreaCode string `bson:"area_code"` PhoneVisibility int32 `bson:"phone_visibility"` CallAcceptSetting int32 `bson:"call_accept_setting"` MsgReceiveSetting int32 `bson:"msg_receive_setting"` diff --git a/protocol b/protocol index 8bdb641d1..3b211f91d 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit 8bdb641d1356efc61620c0d37647a86f5dc94973 +Subproject commit 3b211f91d0e6b98797f91ba34fa64a7b47df5645 From e37cea2d6469368a860b1efa23973a0c6c510a50 Mon Sep 17 00:00:00 2001 From: hawklin2017 <32898629+hawklin2017@users.noreply.github.com> Date: Wed, 6 May 2026 21:08:38 +0800 Subject: [PATCH 10/10] update area_code --- pkg/common/storage/database/mgo/user.go | 49 ++++++++++++------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/pkg/common/storage/database/mgo/user.go b/pkg/common/storage/database/mgo/user.go index 15f86fd07..d5f64a5ab 100644 --- a/pkg/common/storage/database/mgo/user.go +++ b/pkg/common/storage/database/mgo/user.go @@ -69,36 +69,33 @@ func (u *UserMgo) UpdateByMap(ctx context.Context, userID string, args map[strin if err := mongoutil.UpdateOne(ctx, u.coll, filter, update, true); err != nil { return err } - - return nil - // Keep user attributes in sync for consumers that read from the "attribute" collection. // Only sync the allowed attribute fields. - //attributeSet := make(map[string]any) - //for _, key := range []string{ - // "nickname", - // "first_name", - // "last_name", - // "full_name", - // "remark", - // "face_url", - // "phone_number", - // "area_code", - //} { - // if v, ok := args[key]; ok { - // attributeSet[key] = v - // } - //} + attributeSet := make(map[string]any) + for _, key := range []string{ + "nickname", + "first_name", + "last_name", + "full_name", + "remark", + "face_url", + "phone_number", + "area_code", + } { + if v, ok := args[key]; ok { + attributeSet[key] = v + } + } //// user collection uses "phone"; attribute collection uses "phone_number". - //if v, ok := args["phone"]; ok { - // attributeSet["phone_number"] = v - //} - //if len(attributeSet) == 0 { - // return nil - //} + if v, ok := args["phone"]; ok { + attributeSet["phone_number"] = v + } + if len(attributeSet) == 0 { + return nil + } - //attributeColl := u.coll.Database().Collection("attribute") - //return mongoutil.UpdateOne(ctx, attributeColl, filter, bson.M{"$set": attributeSet}, true) + attributeColl := u.coll.Database().Collection("attribute") + return mongoutil.UpdateOne(ctx, attributeColl, filter, bson.M{"$set": attributeSet}, true) } func (u *UserMgo) Find(ctx context.Context, userIDs []string) (users []*model.User, err error) {