Skip to content

Commit 610c683

Browse files
authored
FIX: Use split hide profile and presence options (#128)
1 parent a841235 commit 610c683

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.4.0.beta3-dev: a84123531a6865f6e76cd210e769e0ac4d729963
12
< 3.4.0.beta1-dev: 1294355185bb29e61d381d63b9b4036cc7af9fc9
23
< 3.3.0.beta1-dev: da1be75dae1c5218bdc3f7672d804915272c9ee9
34
3.1.999: 83d3d61797ba989e5ddea8786235b9ade9ad57af

app/models/user_follower.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def self.filter_opted_out_users(relation)
4545
SQL
4646
end
4747
relation.joins("LEFT OUTER JOIN user_options uo ON uo.user_id = users.id").where(
48-
"uo.user_id IS NULL OR NOT uo.hide_profile_and_presence",
48+
"uo.user_id IS NULL OR NOT uo.hide_profile",
4949
)
5050
end
5151

lib/follow/notification_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def handle
1313
return if [Post.types[:regular], Post.types[:whisper]].exclude?(post.post_type)
1414
return if !SiteSetting.follow_notifications_enabled
1515
return if !post.user.allow_people_to_follow_me
16-
return if post.user.user_option&.hide_profile_and_presence
16+
return if post.user.user_option&.hide_profile
1717

1818
topic = post.topic
1919
return if !topic || topic.private_message?

lib/follow/updater.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def follow(notification_level)
5252
)
5353
end
5454

55-
if @target.user_option&.hide_profile_and_presence
55+
if @target.user_option&.hide_profile
5656
raise Discourse::InvalidAccess.new(
5757
nil,
5858
nil,

lib/follow/user_extension.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ def self.prepended(base)
55
base.has_many :follower_relations, class_name: "UserFollower", dependent: :delete_all
66
base.has_many :followers,
77
->(user) do
8-
if !user.allow_people_to_follow_me ||
9-
user.user_option&.hide_profile_and_presence
8+
if !user.allow_people_to_follow_me || user.user_option&.hide_profile
109
where("1=0")
1110
end
1211
end,

spec/integration/follow_notifications_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def follow_notification_assertions(notification, followed, post, topic)
397397
context "when the followed user has hidden profile but has existing followers" do
398398
it "the followers no longer receive notification for posts made by the followed user" do
399399
expect(followed.followers.count).to be > 0
400-
followed.user_option.update!(hide_profile_and_presence: true)
400+
followed.user_option.update!(hide_profile: true)
401401
create_topic(user: followed).tap { |t| create_post(topic: t, user: followed) }
402402
followed.followers.each { |follower| expect(follower.notifications.count).to eq(0) }
403403
end

spec/lib/updater_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def new_updater(follower, target)
169169
end
170170

171171
it "does not allow following a user who has hidden their profile" do
172-
user2.user_option.update!(hide_profile_and_presence: true)
172+
user2.user_option.update!(hide_profile: true)
173173
expect do new_updater(user1, user2).watch_follow end.to raise_error do |error|
174174
expect(error).to be_a(Discourse::InvalidAccess)
175175
expect(error.custom_message).to eq("follow.user_does_not_allow_follow")

spec/models/user_follower_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
it "does not include posts from followed users who have hidden their profile" do
140140
post1 = Fabricate(:post, user: followed)
141141
post2 = Fabricate(:post, user: followed2)
142-
followed.user_option.update!(hide_profile_and_presence: true)
142+
followed.user_option.update!(hide_profile: true)
143143
posts = UserFollower.posts_for(follower, current_user: follower)
144144
expect(posts.pluck(:id)).to contain_exactly(post2.id)
145145
end

spec/models/user_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
end
3535

3636
it "returns empty relation if the user has hidden their profile" do
37-
followed1.user_option.update!(hide_profile_and_presence: true)
37+
followed1.user_option.update!(hide_profile: true)
3838
expect(followed1.followers.pluck(:id)).to be_empty
3939
expect(followed2.followers.pluck(:id)).to contain_exactly(follower1.id, follower2.id)
4040
end
@@ -70,7 +70,7 @@
7070
end
7171

7272
it "excludes users who have hidden their profile" do
73-
followed1.user_option.update!(hide_profile_and_presence: true)
73+
followed1.user_option.update!(hide_profile: true)
7474

7575
expect(follower1.following.pluck(:id)).to contain_exactly(followed2.id)
7676
expect(follower2.following.pluck(:id)).to contain_exactly(followed2.id)

0 commit comments

Comments
 (0)