De-syndicate posts
This commit is contained in:
29
slices/admin/commands/posts/de_syndicate.rb
Normal file
29
slices/admin/commands/posts/de_syndicate.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
Reference in New Issue
Block a user