2014-01-01 03:37:43 +08:00
|
|
|
require_dependency 'email/sender'
|
|
|
|
require_dependency 'topic_retriever'
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
|
|
|
|
# Asynchronously retrieve a topic from an embedded site
|
|
|
|
class RetrieveTopic < Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
raise Discourse::InvalidParameters.new(:embed_url) unless args[:embed_url].present?
|
|
|
|
|
|
|
|
user = nil
|
|
|
|
if args[:user_id]
|
2014-05-06 21:41:59 +08:00
|
|
|
user = User.find_by(id: args[:user_id])
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|
2014-04-25 00:48:45 +08:00
|
|
|
TopicRetriever.new(args[:embed_url], author_username: args[:author_username], no_throttle: user.try(:staff?)).retrieve
|
2014-01-01 03:37:43 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|