Unfollow removes the mark the user to follow the other user.
(ctx context.Context, userID, followID int64)
| 649 | |
| 650 | // Unfollow removes the mark the user to follow the other user. |
| 651 | func (s *UsersStore) Unfollow(ctx context.Context, userID, followID int64) error { |
| 652 | if userID == followID { |
| 653 | return nil |
| 654 | } |
| 655 | |
| 656 | return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error { |
| 657 | err := tx.Where("user_id = ? AND follow_id = ?", userID, followID).Delete(&Follow{}).Error |
| 658 | if err != nil { |
| 659 | return errors.Wrap(err, "delete") |
| 660 | } |
| 661 | return s.recountFollows(tx, userID, followID) |
| 662 | }) |
| 663 | } |
| 664 | |
| 665 | // IsFollowing returns true if the user is following the other user. |
| 666 | func (s *UsersStore) IsFollowing(ctx context.Context, userID, followID int64) bool { |