2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-12-31 14:37:43 -05:00
|
|
|
module Jobs
|
|
|
|
|
|
|
|
# Asynchronously retrieve a topic from an embedded site
|
2019-10-02 00:01:53 -04:00
|
|
|
class RetrieveTopic < ::Jobs::Base
|
2013-12-31 14:37:43 -05:00
|
|
|
|
|
|
|
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
|