Add stubs for remaining webmention types
This commit is contained in:
@@ -22,6 +22,8 @@ module Adamantium
|
|||||||
res.status = 201
|
res.status = 201
|
||||||
in Failure(:invalid_request)
|
in Failure(:invalid_request)
|
||||||
res.status = 429
|
res.status = 429
|
||||||
|
in Failure(:not_implemented)
|
||||||
|
res.status = 429
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@@ -2,11 +2,11 @@ require "dry/monads"
|
|||||||
|
|
||||||
module Adamantium
|
module Adamantium
|
||||||
class WebmentionRequestParser
|
class WebmentionRequestParser
|
||||||
|
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
|
|
||||||
def call(params:)
|
def call(params:)
|
||||||
if params[:"wm-property"] == "in-reply-to"
|
case params[:"wm-property"]
|
||||||
|
when "in-reply-to"
|
||||||
Success[:reply, {
|
Success[:reply, {
|
||||||
type: "reply",
|
type: "reply",
|
||||||
author_name: params[:author][:name],
|
author_name: params[:author][:name],
|
||||||
@@ -18,6 +18,16 @@ module Adamantium
|
|||||||
source_url: params[:url],
|
source_url: params[:url],
|
||||||
target_url: params[:"in-reply-to"]
|
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
|
else
|
||||||
Failure(:invalid_request)
|
Failure(:invalid_request)
|
||||||
end
|
end
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
#
|
|
||||||
RSpec.describe Adamantium::WebmentionRequestParser do
|
RSpec.describe Adamantium::WebmentionRequestParser do
|
||||||
include Dry::Monads[:result]
|
include Dry::Monads[:result]
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
@@ -39,4 +39,3 @@ RSpec.describe Adamantium::WebmentionRequestParser do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -7,22 +7,22 @@ RSpec.describe "Webmention creation", :db, :requests do
|
|||||||
context "reply" do
|
context "reply" do
|
||||||
let(:reply_json) {
|
let(:reply_json) {
|
||||||
{
|
{
|
||||||
"type": "entry",
|
type: "entry",
|
||||||
"author": {
|
author: {
|
||||||
"type": "card",
|
type: "card",
|
||||||
"name": "nitza",
|
name: "nitza",
|
||||||
"photo": "",
|
photo: "",
|
||||||
"url": "https://micro.blog/nitza"
|
url: "https://micro.blog/nitza"
|
||||||
},
|
},
|
||||||
"url": "https://micro.blog/nitza/20554783",
|
url: "https://micro.blog/nitza/20554783",
|
||||||
"published": "2023-07-05T09:44:41+00:00",
|
published: "2023-07-05T09:44:41+00:00",
|
||||||
"wm-received": "2023-07-05T09:44:48Z",
|
"wm-received": "2023-07-05T09:44:48Z",
|
||||||
"wm-id": 1692950,
|
"wm-id": 1692950,
|
||||||
"wm-source": "https://micro.blog/nitza/20554783",
|
"wm-source": "https://micro.blog/nitza/20554783",
|
||||||
"wm-target": "https://dnitza.com/post/#{post_record.slug}",
|
"wm-target": "https://dnitza.com/post/#{post_record.slug}",
|
||||||
"content": {
|
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>",
|
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 😅"
|
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}",
|
"in-reply-to": "https://dnitza.com/post/#{post_record.slug}",
|
||||||
"wm-property": "in-reply-to",
|
"wm-property": "in-reply-to",
|
||||||
@@ -38,4 +38,4 @@ RSpec.describe "Webmention creation", :db, :requests do
|
|||||||
expect(last_response).to be_successful
|
expect(last_response).to be_successful
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user