2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-12-31 13:37:43 -06:00
|
|
|
module Jobs
|
|
|
|
# Asynchronously retrieve a topic from an embedded site
|
2019-10-01 23:01:53 -05:00
|
|
|
class RetrieveTopic < ::Jobs::Base
|
2013-12-31 13:37:43 -06:00
|
|
|
def execute(args)
|
2024-05-27 05:27:13 -05:00
|
|
|
raise Discourse::InvalidParameters.new(:embed_url) if args[:embed_url].blank?
|
2013-12-31 13:37:43 -06:00
|
|
|
|
|
|
|
user = nil
|
2023-01-09 06:20:10 -06:00
|
|
|
user = User.find_by(id: args[:user_id]) if args[:user_id]
|
|
|
|
TopicRetriever.new(
|
|
|
|
args[:embed_url],
|
|
|
|
author_username: args[:author_username],
|
|
|
|
no_throttle: user.try(:staff?),
|
|
|
|
).retrieve
|
2013-12-31 13:37:43 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|