2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-01-01 03:37:43 +08:00
|
|
|
module Jobs
|
|
|
|
# Asynchronously retrieve a topic from an embedded site
|
2019-10-02 12:01:53 +08:00
|
|
|
class RetrieveTopic < ::Jobs::Base
|
2014-01-01 03:37:43 +08:00
|
|
|
def execute(args)
|
2024-05-27 18:27:13 +08:00
|
|
|
raise Discourse::InvalidParameters.new(:embed_url) if args[:embed_url].blank?
|
2014-01-01 03:37:43 +08:00
|
|
|
|
|
|
|
user = nil
|
2014-05-06 21:41:59 +08:00
|
|
|
user = User.find_by(id: args[:user_id]) if args[:user_id]
|
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
|