add friend with remark

pull/3727/head
hawklin2017 1 month ago
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
}

@ -1 +1 @@
Subproject commit ba5857cc0817dcfaf6892af0c542385b71f46377
Subproject commit 7f613eb71f23a69730cfb3c3abd1515da0fb17cf
Loading…
Cancel
Save