mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Remove UserFirst for mention since it can be retrieved elsewhere
This commit is contained in:
parent
b1d04412db
commit
5866f0df18
@ -1,7 +1,9 @@
|
|||||||
class UserFirst < ActiveRecord::Base
|
class UserFirst < ActiveRecord::Base
|
||||||
|
|
||||||
def self.types
|
def self.types
|
||||||
@types ||= Enum.new(used_emoji: 1, mentioned_user: 2)
|
@types ||= Enum.new(used_emoji: 1,
|
||||||
|
mentioned_user: 2 #unused now
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_for(user_id, type, post_id=nil)
|
def self.create_for(user_id, type, post_id=nil)
|
||||||
|
@ -365,10 +365,10 @@ Badge.seed do |b|
|
|||||||
b.multiple_grant = false
|
b.multiple_grant = false
|
||||||
b.target_posts = true
|
b.target_posts = true
|
||||||
b.show_posts = true
|
b.show_posts = true
|
||||||
b.query = BadgeQueries.has_user_first(:mentioned_user)
|
b.query = BadgeQueries::FirstMention
|
||||||
b.badge_grouping_id = BadgeGrouping::GettingStarted
|
b.badge_grouping_id = BadgeGrouping::GettingStarted
|
||||||
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
|
||||||
b.trigger = Badge::Trigger::PostProcessed
|
b.trigger = Badge::Trigger::PostRevision
|
||||||
b.system = true
|
b.system = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,6 +134,22 @@ SQL
|
|||||||
HAVING COUNT(p.id) > 0
|
HAVING COUNT(p.id) > 0
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
FirstMention = <<-SQL
|
||||||
|
SELECT acting_user_id AS user_id, min(target_post_id) AS post_id, min(p.created_at) AS granted_at
|
||||||
|
FROM user_actions
|
||||||
|
JOIN posts p ON p.id = target_post_id
|
||||||
|
JOIN topics t ON t.id = topic_id
|
||||||
|
JOIN categories c on c.id = category_id
|
||||||
|
WHERE action_type = 7
|
||||||
|
AND NOT read_restricted
|
||||||
|
AND p.deleted_at IS NULL
|
||||||
|
AND t.deleted_at IS NULL
|
||||||
|
AND t.visible
|
||||||
|
AND t.archetype <> 'private_message'
|
||||||
|
AND (:backfill OR p.id IN (:post_ids))
|
||||||
|
GROUP BY acting_user_id
|
||||||
|
SQL
|
||||||
|
|
||||||
def self.invite_badge(count,trust_level)
|
def self.invite_badge(count,trust_level)
|
||||||
"
|
"
|
||||||
SELECT u.id user_id, current_timestamp granted_at
|
SELECT u.id user_id, current_timestamp granted_at
|
||||||
|
@ -45,10 +45,6 @@ class CookedPostProcessor
|
|||||||
created |= UserFirst.create_for(@post.user_id, :used_emoji, @post.id)
|
created |= UserFirst.create_for(@post.user_id, :used_emoji, @post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @doc.css("span.mention, a.mention").size > 0
|
|
||||||
created |= UserFirst.create_for(@post.user_id, :mentioned_user, @post.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
if created
|
if created
|
||||||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostProcessed, user: @post.user)
|
BadgeGranter.queue_badge_grant(Badge::Trigger::PostProcessed, user: @post.user)
|
||||||
end
|
end
|
||||||
|
@ -31,17 +31,6 @@ describe UserFirst do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'mentioning' do
|
|
||||||
let(:codinghorror) { Fabricate(:codinghorror) }
|
|
||||||
|
|
||||||
it "creates one the first time a user mentions another" do
|
|
||||||
post = PostCreator.create(user, title: "gonna mention another user", raw: "what is up @codinghorror?")
|
|
||||||
uf = UserFirst.where(user_id: user.id, first_type: UserFirst.types[:mentioned_user]).first
|
|
||||||
expect(uf).to be_present
|
|
||||||
expect(uf.post_id).to eq(post.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "privacy" do
|
context "privacy" do
|
||||||
let(:codinghorror) { Fabricate(:codinghorror) }
|
let(:codinghorror) { Fabricate(:codinghorror) }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user