mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
BUGFIX: no reading credit for posts you create
This commit is contained in:
parent
2eac7128dc
commit
c6c412fd45
2 changed files with 23 additions and 3 deletions
|
@ -269,13 +269,21 @@ class PostCreator
|
||||||
def track_topic
|
def track_topic
|
||||||
return if @opts[:auto_track] == false
|
return if @opts[:auto_track] == false
|
||||||
|
|
||||||
TopicUser.auto_track(@user.id, @topic.id, TopicUser.notification_reasons[:created_post])
|
|
||||||
# Update topic user data
|
|
||||||
TopicUser.change(@post.user.id,
|
TopicUser.change(@post.user.id,
|
||||||
@post.topic.id,
|
@post.topic.id,
|
||||||
posted: true,
|
posted: true,
|
||||||
last_read_post_number: @post.post_number,
|
last_read_post_number: @post.post_number,
|
||||||
seen_post_count: @post.post_number)
|
seen_post_count: @post.post_number)
|
||||||
|
|
||||||
|
|
||||||
|
# assume it took us 5 seconds of reading time to make a post
|
||||||
|
PostTiming.record_timing(topic_id: @post.topic_id,
|
||||||
|
user_id: @post.user_id,
|
||||||
|
post_number: @post.post_number,
|
||||||
|
msecs: 5000)
|
||||||
|
|
||||||
|
|
||||||
|
TopicUser.auto_track(@user.id, @topic.id, TopicUser.notification_reasons[:created_post])
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_jobs
|
def enqueue_jobs
|
||||||
|
|
|
@ -429,10 +429,22 @@ describe PostCreator do
|
||||||
embed_url: embed_url,
|
embed_url: embed_url,
|
||||||
title: 'Reviews of Science Ovens',
|
title: 'Reviews of Science Ovens',
|
||||||
raw: 'Did you know that you can use microwaves to cook your dinner? Science!')
|
raw: 'Did you know that you can use microwaves to cook your dinner? Science!')
|
||||||
post = creator.create
|
creator.create
|
||||||
TopicEmbed.where(embed_url: embed_url).exists?.should be_true
|
TopicEmbed.where(embed_url: embed_url).exists?.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "read credit for creator" do
|
||||||
|
it "should give credit to creator" do
|
||||||
|
post = create_post
|
||||||
|
PostTiming.find_by(topic_id: post.topic_id,
|
||||||
|
post_number: post.post_number,
|
||||||
|
user_id: post.user_id).msecs.should be > 0
|
||||||
|
|
||||||
|
TopicUser.find_by(topic_id: post.topic_id,
|
||||||
|
user_id: post.user_id).last_read_post_number.should == 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue