Refactor micropub specific things out to a slice

This commit is contained in:
2023-11-15 18:55:57 +11:00
parent 730ecb9ea4
commit 5b133363b3
63 changed files with 468 additions and 174 deletions

View File

@@ -0,0 +1,32 @@
# frozen_string_literal: true
module Micropub
module Actions
module Webmentions
class Create < Adamantium::Action
include Deps["repos.webmentions_repo",
"repos.post_repo",
webmention_parser: "param_parser.webmention"
]
def handle(req, res)
webmention = webmention_parser.call(params: req.params)
case webmention
in Success[:reply, reply]
slug = req.params[:"in-reply-to"].split("/").last
post = post_repo.fetch!(slug)
reply[:post_id] = post.id
webmentions_repo.create(reply)
res.status = 201
in Failure(:invalid_request)
res.status = 429
in Failure(:not_implemented)
res.status = 429
end
end
end
end
end
end