Refactor post creation + syndication

This commit is contained in:
2023-02-12 21:58:18 +11:00
parent b3b287bbf4
commit 2b81839127
5 changed files with 46 additions and 33 deletions

View File

@@ -1,9 +1,5 @@
require "securerandom"
module Adamantium
class MicropubRequestParser
include Deps["post_utilities.slugify", "repos.post_repo"]
def call(params:)
return nil if params.key?(:action)
@@ -20,15 +16,6 @@ module Adamantium
private
def slug(name:, default_slug:)
return default_slug if default_slug
slugify.call(
text: name,
checker: post_repo.method(:slug_exists?)
)
end
def content_type(params)
return :bookmark if params[:"bookmark-of"]
:post
@@ -81,7 +68,7 @@ module Adamantium
new_params[:content] = content
end
new_params[:url] = params[:"bookmark-of"]
new_params[:slug] = slug(name: new_params[:name], default_slug: params[:slug])
new_params[:slug] = params[:slug]
new_params
end