Refactor post creation + syndication

This commit is contained in:
2023-02-12 21:58:18 +11:00
parent b3b287bbf4
commit 2b81839127
5 changed files with 46 additions and 33 deletions

View File

@@ -1,10 +1,22 @@
require "dry/monads"
module Adamantium
module Commands
module Posts
class CreateBookmark < Command
include Deps["repos.post_repo"]
include Deps["repos.post_repo", syndicate: "commands.posts.syndicate"]
include Dry::Monads[:result]
def call(bookmark)
post_repo.create(bookmark)
created_bookmark = post_repo.create(bookmark)
syndicate.call(bookmark).bind do |result|
source, url = result
add_post_syndication_source.call(created_bookmark.id, source, url)
end
Success(created_bookmark)
end
end
end