2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-12-31 14:37:43 -05: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 09:41:59 -04:00
|
|
|
user = User.find_by(id: args[:user_id])
|
2013-12-31 14:37:43 -05:00
|
|
|
end
|
2014-04-24 12:48:45 -04:00
|
|
|
TopicRetriever.new(args[:embed_url], author_username: args[:author_username], no_throttle: user.try(:staff?)).retrieve
|
2013-12-31 14:37:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|