Refactor post creation + syndication
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user