Use new event to trigger vote_release
This commit is contained in:
parent
b7c503d3c2
commit
6d926ab101
22
plugin.rb
22
plugin.rb
|
@ -109,7 +109,7 @@ after_initialize do
|
||||||
def vote_limit
|
def vote_limit
|
||||||
object.vote_limit
|
object.vote_limit
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require_dependency 'topic'
|
require_dependency 'topic'
|
||||||
|
@ -133,6 +133,26 @@ after_initialize do
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
require_dependency "jobs/base"
|
||||||
|
module ::Jobs
|
||||||
|
class VoteRelease < Jobs::Base
|
||||||
|
def execute(args)
|
||||||
|
byebug
|
||||||
|
if topic = Topic.find_by(id: args[:topic_id])
|
||||||
|
byebug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
DiscourseEvent.on(:topic_status_updated) do |topic_id, status, enabled|
|
||||||
|
if status == 'closed' && enabled == true
|
||||||
|
byebug
|
||||||
|
Jobs.enqueue(:vote_release, {topic_id: topic_id})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Discourse::Application.routes.append do
|
Discourse::Application.routes.append do
|
||||||
|
|
Loading…
Reference in New Issue