Files
adamantium/slices/admin/commands/posts/de_syndicate.rb
2024-02-03 08:39:18 +11:00

30 lines
685 B
Ruby

require "readability"
require "down"
module Admin
module Commands
module Posts
class DeSyndicate
include Dry::Monads[:result]
include Deps["repos.post_repo", "syndication.mastodon"]
def call(post_id:, target:)
post = post_repo.find(id: post_id)
request = if target.to_sym == :mastodon
masto_id = post.syndication_sources[target].split("/").last
mastodon.de_syndicate(post_id: masto_id)
end
if request.success?
post.syndication_sources.delete(target)
post_repo.update(post_id, post)
end
Success()
end
end
end
end
end