Save syndication sources to posts

This commit is contained in:
2023-01-29 16:54:34 +11:00
parent 37932ea4ad
commit 2d371812f5
17 changed files with 231 additions and 10 deletions

View File

@@ -11,7 +11,8 @@ module Adamantium
delete_post: "commands.posts.delete",
undelete_post: "commands.posts.undelete",
update_post: "commands.posts.update",
syndicate: "commands.posts.syndicate"
syndicate: "commands.posts.syndicate",
add_post_syndication_source: "commands.posts.add_syndication_source"
]
def handle(req, res)
@@ -36,10 +37,13 @@ module Adamantium
validation = contract.call(req_entity.to_h)
if validation.success?
url = syndicate.call(validation.to_h) # TODO: set URL on post
post = command.call(validation.to_h)
syndicate.call(validation.to_h).bind do |result|
source, url = result
add_post_syndication_source.call(post.id, source, url)
end
res.status = 201
res.headers.merge!(
"Location" => "#{settings.micropub_site_url}/#{post.post_type}/#{post.slug}"