Add ability to cache bookmark

This commit is contained in:
2023-07-29 18:06:05 +10:00
parent 46c5d7a4aa
commit 19aff274de
9 changed files with 60 additions and 45 deletions

View File

@@ -5,8 +5,9 @@ module Adamantium
module Posts
class CreateBookmark < Command
include Deps["repos.post_repo",
"post_utilities.page_cacher",
syndicate: "commands.posts.syndicate",
raindrop: "syndication.raindrop"
raindrop: "syndication.raindrop",
]
include Dry::Monads[:result]
@@ -17,6 +18,12 @@ module Adamantium
syndicate.call(created_bookmark.id, bookmark)
raindrop.call(post: created_bookmark)
if bookmark[:cache]
page_cacher.call(url: created_bookmark.url) do |content|
post_repo.update(id: created_bookmark.id, cached_content: content)
end
end
Success(created_bookmark)
end
end

View File

@@ -4,6 +4,7 @@ module Adamantium
attribute :h, Types::Coercible::String
attribute :action, Types::Coercible::String.optional
attribute :name, Types::Coercible::String
attribute :cache, Types::Bool.optional
attribute :content, Types::Coercible::String.optional
attribute :url, Types::Coercible::String
attribute :slug, Types::Coercible::String