Allow adding of syndication sources after a post is created
This commit is contained in:
22
slices/admin/commands/posts/add_syndication_source.rb
Normal file
22
slices/admin/commands/posts/add_syndication_source.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require "readability"
|
||||
require "down"
|
||||
|
||||
module Admin
|
||||
module Commands
|
||||
module Posts
|
||||
class AddSyndicationSource
|
||||
include Dry::Monads[:result]
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
def call(post_id:, source_name:, source_url:)
|
||||
post = post_repo.find(id: post_id)
|
||||
syndication_sources = post[:syndication_sources]
|
||||
updated_syndication_sources = syndication_sources.merge(source_name => source_url)
|
||||
|
||||
post_repo.update(post_id, syndication_sources: updated_syndication_sources)
|
||||
Success()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user