mirror of
https://ghfast.top/https://github.com/discourse/discourse-follow.git
synced 2026-07-15 11:36:38 +08:00
If a user you follow hides their profile, we were not allowing user to unfollow, causing confusion and problems.
17 lines
671 B
Ruby
17 lines
671 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Follow::UserExtension
|
|
def self.prepended(base)
|
|
base.has_many :follower_relations, class_name: 'UserFollower', dependent: :delete_all
|
|
base.has_many :followers, -> (user) {
|
|
if !user.allow_people_to_follow_me || user.user_option&.hide_profile_and_presence
|
|
where("1=0")
|
|
end
|
|
}, through: :follower_relations, source: :follower_user
|
|
|
|
base.has_many :following_relations, class_name: 'UserFollower', foreign_key: :follower_id, dependent: :delete_all
|
|
base.has_many :following, -> {
|
|
UserFollower.filter_opted_out_users(self)
|
|
}, through: :following_relations, source: :followed_user
|
|
end
|
|
end
|