Send web mentions in the background
This commit is contained in:
@@ -23,9 +23,9 @@ module Adamantium
|
||||
|
||||
syndicate.call(created_post.id, post)
|
||||
|
||||
# decorated_post = Decorators::Posts::Decorator.new(created_post)
|
||||
decorated_post = Decorators::Posts::Decorator.new(created_post)
|
||||
|
||||
# send_webmentions.call(post_content: attrs[:content], post_url: decorated_post.permalink)
|
||||
send_webmentions.call(post_content: created_post.content, post_url: decorated_post.permalink)
|
||||
|
||||
Success(created_post)
|
||||
end
|
||||
|
@@ -1,4 +1,5 @@
|
||||
require "httparty"
|
||||
require "que"
|
||||
|
||||
module Adamantium
|
||||
module Commands
|
||||
@@ -7,15 +8,9 @@ module Adamantium
|
||||
include Deps["settings", "post_utilities.link_finder"]
|
||||
|
||||
def call(post_content:, post_url:)
|
||||
source = post_url
|
||||
links = link_finder.call(post_content)
|
||||
links.each do |target|
|
||||
HTTParty.post(settings.webmention_service, {
|
||||
token: settings.webmention_token,
|
||||
source: source,
|
||||
target: target
|
||||
})
|
||||
end
|
||||
Que.connection = Adamantium::Container["persistence.db"]
|
||||
|
||||
Adamantium::Jobs::SendWebMentions.enqueue(post_content: post_content, post_url: post_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -22,7 +22,8 @@ module Adamantium
|
||||
|
||||
config.shared_app_component_keys += [
|
||||
"syndication.dayone",
|
||||
"renderers.markdown"
|
||||
"renderers.markdown",
|
||||
"post_utilities.link_finder"
|
||||
]
|
||||
|
||||
config.assets.manifest_path = Hanami.env == :production ? "public/assets/asset-manifest.json" : nil
|
||||
|
23
lib/adamantium/jobs/send_web_mentions.rb
Normal file
23
lib/adamantium/jobs/send_web_mentions.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require "httparty"
|
||||
require "que"
|
||||
|
||||
module Adamantium
|
||||
module Jobs
|
||||
class SendWebMentions < Que::Job
|
||||
def run(post_content:, post_url:)
|
||||
link_finder = Admin::Container["post_utilities.link_finder"]
|
||||
settings = Admin::Container["settings"]
|
||||
|
||||
source = post_url
|
||||
links = link_finder.call(post_content)
|
||||
links.each do |target|
|
||||
HTTParty.post(settings.webmention_service, {
|
||||
token: settings.webmention_token,
|
||||
source: source,
|
||||
target: target
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user