Add ability to cache bookmark
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user