From e19b86a4c1d0de50da87891b2293fee79720654b Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Thu, 21 Dec 2023 20:29:45 +1100 Subject: [PATCH] Support "like" web mentions --- lib/adamantium/webmention_request_parser.rb | 11 +++++++++++ slices/micropub/actions/webmentions/create.rb | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/adamantium/webmention_request_parser.rb b/lib/adamantium/webmention_request_parser.rb index c9f3afb..772660c 100644 --- a/lib/adamantium/webmention_request_parser.rb +++ b/lib/adamantium/webmention_request_parser.rb @@ -21,6 +21,17 @@ module Adamantium target_url: wm_params[:"in-reply-to"] }] when "like-of" + Success[:like, { + type: "like", + author_name: wm_params[:author][:name], + author_photo: wm_params[:author][:photo], + author_url: wm_params[:author][:url], + published_at: wm_params[:published], + content_html: wm_params[:content][:html], + content_text: wm_params[:content][:text], + source_url: wm_params[:url], + target_url: wm_params[:"in-reply-to"] + }] Failure(:not_implemented) when "repost-of" Failure(:not_implemented) diff --git a/slices/micropub/actions/webmentions/create.rb b/slices/micropub/actions/webmentions/create.rb index d878799..59a2923 100644 --- a/slices/micropub/actions/webmentions/create.rb +++ b/slices/micropub/actions/webmentions/create.rb @@ -18,6 +18,17 @@ module Micropub reply[:post_id] = post.id + webmentions_repo.create(reply) + res.body = { + result: "Webmention was successful" + }.to_json + res.status = 202 + in Success[:like, like] + slug = req.params[:"like-of"].split("/").last + post = post_repo.fetch!(slug) + + reply[:post_id] = post.id + webmentions_repo.create(reply) res.body = { result: "Webmention was successful"