Add stubs for remaining webmention types

This commit is contained in:
2023-07-06 21:14:23 +10:00
parent bee8adc407
commit 0083443168
4 changed files with 27 additions and 16 deletions

View File

@@ -22,6 +22,8 @@ module Adamantium
res.status = 201
in Failure(:invalid_request)
res.status = 429
in Failure(:not_implemented)
res.status = 429
end
end
end

View File

@@ -2,11 +2,11 @@ require "dry/monads"
module Adamantium
class WebmentionRequestParser
include Dry::Monads[:result]
def call(params:)
if params[:"wm-property"] == "in-reply-to"
case params[:"wm-property"]
when "in-reply-to"
Success[:reply, {
type: "reply",
author_name: params[:author][:name],
@@ -18,6 +18,16 @@ module Adamantium
source_url: params[:url],
target_url: params[:"in-reply-to"]
}]
when "like-of"
Failure(:not_implemented)
when "repost-of"
Failure(:not_implemented)
when "bookmark-of"
Failure(:not_implemented)
when "mention-of"
Failure(:not_implemented)
when "rsvp"
Failure(:not_implemented)
else
Failure(:invalid_request)
end

View File

@@ -1,5 +1,5 @@
# frozen_string_literal: true
#
RSpec.describe Adamantium::WebmentionRequestParser do
include Dry::Monads[:result]
subject { described_class.new }
@@ -39,4 +39,3 @@ RSpec.describe Adamantium::WebmentionRequestParser do
end
end
end

View File

@@ -7,22 +7,22 @@ RSpec.describe "Webmention creation", :db, :requests do
context "reply" do
let(:reply_json) {
{
"type": "entry",
"author": {
"type": "card",
"name": "nitza",
"photo": "",
"url": "https://micro.blog/nitza"
type: "entry",
author: {
type: "card",
name: "nitza",
photo: "",
url: "https://micro.blog/nitza"
},
"url": "https://micro.blog/nitza/20554783",
"published": "2023-07-05T09:44:41+00:00",
url: "https://micro.blog/nitza/20554783",
published: "2023-07-05T09:44:41+00:00",
"wm-received": "2023-07-05T09:44:48Z",
"wm-id": 1692950,
"wm-source": "https://micro.blog/nitza/20554783",
"wm-target": "https://dnitza.com/post/#{post_record.slug}",
"content": {
"html": "<p><a href=\"https://micro.blog/example\">@example</a> hah! I thought the same thing — but this is the most affordable thing that Teenage Engineering makes 😅</p>",
"text": "@example hah! I thought the same thing — but this is the most affordable thing that Teenage Engineering makes 😅"
content: {
html: "<p><a href=\"https://micro.blog/example\">@example</a> hah! I thought the same thing — but this is the most affordable thing that Teenage Engineering makes 😅</p>",
text: "@example hah! I thought the same thing — but this is the most affordable thing that Teenage Engineering makes 😅"
},
"in-reply-to": "https://dnitza.com/post/#{post_record.slug}",
"wm-property": "in-reply-to",
@@ -38,4 +38,4 @@ RSpec.describe "Webmention creation", :db, :requests do
expect(last_response).to be_successful
end
end
end
end