FEATURE: Show first notification tip to all users (#22258)
It used to show only to users with trust level 0 or 1 and users who signed up in the past week.
This commit is contained in:
parent
d65c7d6ce3
commit
d888a8b692
|
@ -808,20 +808,8 @@ class User < ActiveRecord::Base
|
||||||
MessageBus.publish("/reviewable_counts/#{self.id}", data, user_ids: [self.id])
|
MessageBus.publish("/reviewable_counts/#{self.id}", data, user_ids: [self.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
TRACK_FIRST_NOTIFICATION_READ_DURATION = 1.week.to_i
|
|
||||||
|
|
||||||
def read_first_notification?
|
def read_first_notification?
|
||||||
if (
|
self.seen_notification_id != 0 || user_option.skip_new_user_tips
|
||||||
trust_level > TrustLevel[1] ||
|
|
||||||
(
|
|
||||||
first_seen_at.present? &&
|
|
||||||
first_seen_at < TRACK_FIRST_NOTIFICATION_READ_DURATION.seconds.ago
|
|
||||||
) || user_option.skip_new_user_tips
|
|
||||||
)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
self.seen_notification_id == 0 ? false : true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_notifications_state
|
def publish_notifications_state
|
||||||
|
|
|
@ -2208,22 +2208,6 @@ RSpec.describe User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when user is trust level 2" do
|
|
||||||
it "should return the right value" do
|
|
||||||
user.update!(trust_level: TrustLevel[2])
|
|
||||||
|
|
||||||
expect(user.read_first_notification?).to eq(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "when user is an old user" do
|
|
||||||
it "should return the right value" do
|
|
||||||
user.update!(first_seen_at: 1.year.ago)
|
|
||||||
|
|
||||||
expect(user.read_first_notification?).to eq(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "when user skipped new user tips" do
|
describe "when user skipped new user tips" do
|
||||||
it "should return the right value" do
|
it "should return the right value" do
|
||||||
user.user_option.update!(skip_new_user_tips: true)
|
user.user_option.update!(skip_new_user_tips: true)
|
||||||
|
|
Loading…
Reference in New Issue