Fix webmention hook

This commit is contained in:
2023-07-05 19:50:36 +10:00
parent ee37b6622d
commit b828d59716
2 changed files with 17 additions and 19 deletions

View File

@@ -8,27 +8,25 @@ module Adamantium
include Deps["repos.webmentions_repo", "repos.post_repo"] include Deps["repos.webmentions_repo", "repos.post_repo"]
def handle(req, res) def handle(req, res)
req.params[:children].each do |child| if req.params[:"wm-property"] == "in-reply-to"
if child[:"wm-property"] == "in-reply-to"
slug = child[:"in-reply-to"].split("/").last slug = req.params[:"in-reply-to"].split("/").last
post = post_repo.fetch!(slug) post = post_repo.fetch!(slug)
attrs = { attrs = {
type: "reply", type: "reply",
author_name: child[:author][:name], author_name: req.params[:author][:name],
author_photo: child[:author][:photo], author_photo: req.params[:author][:photo],
author_url: child[:author][:url], author_url: req.params[:author][:url],
published_at: child[:published], published_at: req.params[:published],
content_html: child[:content][:html], content_html: req.params[:content][:html],
content_text: child[:content][:text], content_text: req.params[:content][:text],
source_url: child[:url], source_url: req.params[:url],
target_url: child[:"in-reply-to"], target_url: req.params[:"in-reply-to"],
post_id: post.id post_id: post.id
} }
webmentions_repo.create(attrs) webmentions_repo.create(attrs)
end
end end
end end
end end

View File

@@ -1,3 +1,3 @@
div class="rounded max-w-xs" div class="rounded max-w-xs"
a href="#{post.permalink}" a href="#{post.permalink}"
img class="rounded object-cover transition-transform transform-gpu ease-out hover:scale-105 h-48 w-48" src="#{post.photos[0]["value"]}" alt="#{post.photos[0]["alt"]}" img class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{post.photos[0]["value"]}" alt="#{post.photos[0]["alt"]}"