mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-06-30 06:48:14 +08:00
add friend with remark
This commit is contained in:
parent
ac8062b7c6
commit
6e42d00794
@ -693,7 +693,7 @@ func (s *friendServer) AddOnewayFriend(ctx context.Context, req *relation.ApplyT
|
||||
if in1 {
|
||||
return nil, servererrs.ErrRelationshipAlready.WrapMsg("already in friend list")
|
||||
}
|
||||
if err := s.db.BecomeOnewayFriend(ctx, req.FromUserID, req.ToUserID, becomeFriendByOneway); err != nil {
|
||||
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
|
||||
|
||||
@ -95,7 +95,7 @@ type FriendDatabase interface {
|
||||
|
||||
// BecomeOnewayFriend inserts a single-side friendship: ownerUserID -> friendUserID.
|
||||
// The reverse side (friendUserID -> ownerUserID) is NOT created.
|
||||
BecomeOnewayFriend(ctx context.Context, ownerUserID, friendUserID string, addSource int32) error
|
||||
BecomeOnewayFriend(ctx context.Context, ownerUserID, friendUserID string, addSource int32, remark string) error
|
||||
}
|
||||
|
||||
type friendDatabase struct {
|
||||
@ -415,7 +415,7 @@ func (f *friendDatabase) GetPinnedFriendIDs(ctx context.Context, ownerUserID str
|
||||
|
||||
// BecomeOnewayFriend creates only the ownerUserID->friendUserID side of the friendship.
|
||||
// The reverse side is intentionally omitted so that the target user is not aware of being added.
|
||||
func (f *friendDatabase) BecomeOnewayFriend(ctx context.Context, ownerUserID, friendUserID string, addSource int32) error {
|
||||
func (f *friendDatabase) BecomeOnewayFriend(ctx context.Context, ownerUserID, friendUserID string, addSource int32, remark string) error {
|
||||
return f.tx.Transaction(ctx, func(ctx context.Context) error {
|
||||
existing, err := f.friend.FindFriends(ctx, ownerUserID, []string{friendUserID})
|
||||
if err != nil {
|
||||
@ -427,7 +427,7 @@ func (f *friendDatabase) BecomeOnewayFriend(ctx context.Context, ownerUserID, fr
|
||||
}
|
||||
opUserID := mcontext.GetOpUserID(ctx)
|
||||
if err := f.friend.Create(ctx, []*model.Friend{
|
||||
{OwnerUserID: ownerUserID, FriendUserID: friendUserID, AddSource: addSource, OperatorUserID: opUserID},
|
||||
{OwnerUserID: ownerUserID, FriendUserID: friendUserID, AddSource: addSource, OperatorUserID: opUserID, Remark: remark},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
2
protocol
2
protocol
@ -1 +1 @@
|
||||
Subproject commit ba5857cc0817dcfaf6892af0c542385b71f46377
|
||||
Subproject commit 7f613eb71f23a69730cfb3c3abd1515da0fb17cf
|
||||
Loading…
x
Reference in New Issue
Block a user