pull/1532/head
AndrewZuo01 2 years ago
parent afab3797a9
commit f719c81e71

@ -450,7 +450,6 @@ func (s *friendServer) PinFriends(
} else {
return nil, errs.ErrArgs.Wrap("isPinned is nil")
}
log.ZDebug(ctx, "pinfriend1", "s", req)
//檢查是不是在好友列表裏
_, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
if err != nil {
@ -460,7 +459,6 @@ func (s *friendServer) PinFriends(
//全部置頂
//把所有friendslist的isPinned都設置為isPinned
for _, friendID := range req.FriendUserIDs {
log.ZDebug(ctx, "pinfriend2", "s", req)
if err := s.friendDatabase.UpdateFriendPinStatus(ctx, req.OwnerUserID, friendID, isPinned); err != nil {
return nil, err
}

@ -135,9 +135,12 @@ func (f *FriendMgo) FindFriendUserIDs(ctx context.Context, ownerUserID string) (
func (f *FriendMgo) UpdatePinStatus(ctx context.Context, ownerUserID string, friendUserID string, isPinned bool) (err error) {
filter := bson.M{"owner_user_id": ownerUserID, "friend_user_id": friendUserID}
// Create an update operation to set the "is_pinned" field to false for all documents.
update := bson.M{"$set": bson.M{"is_pinned": isPinned}}
_, err = f.coll.UpdateOne(ctx, filter, update)
// Perform the update operation for all documents in the collection.
_, err = f.coll.UpdateMany(ctx, filter, update)
if err != nil {
return errs.Wrap(err, "update pin error")
}

@ -30,6 +30,7 @@ type FriendModel struct {
AddSource int32 `bson:"add_source"`
OperatorUserID string `bson:"operator_user_id"`
Ex string `bson:"ex"`
isPinned string `bson:"is_pinned"`
}
// FriendModelInterface defines the operations for managing friends in MongoDB.

Loading…
Cancel
Save