Merge branch 'roadhouse' into 'develop'

Roadhouse debugging

See merge request pleroma/pleroma!3628
This commit is contained in:
Alex Gleason 2022-02-02 18:44:09 +00:00
commit 71c80204c9
8 changed files with 297 additions and 0 deletions

View File

@ -0,0 +1,109 @@
{
"@context":[
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"zot":"https://macgirvin.com/apschema#",
"toot":"http://joinmastodon.org/ns#",
"ostatus":"http://ostatus.org#",
"schema":"http://schema.org#",
"litepub":"http://litepub.social/ns#",
"sm":"http://smithereen.software/ns#",
"conversation":"ostatus:conversation",
"manuallyApprovesFollowers":"as:manuallyApprovesFollowers",
"oauthRegistrationEndpoint":"litepub:oauthRegistrationEndpoint",
"sensitive":"as:sensitive",
"movedTo":"as:movedTo",
"copiedTo":"as:copiedTo",
"alsoKnownAs":"as:alsoKnownAs",
"EmojiReact":"as:EmojiReact",
"commentPolicy":"zot:commentPolicy",
"topicalCollection":"zot:topicalCollection",
"eventRepeat":"zot:eventRepeat",
"emojiReaction":"zot:emojiReaction",
"expires":"zot:expires",
"directMessage":"zot:directMessage",
"Category":"zot:Category",
"replyTo":"zot:replyTo",
"PropertyValue":"schema:PropertyValue",
"value":"schema:value",
"discoverable":"toot:discoverable",
"wall":"sm:wall",
"capabilities":"litepub:capabilities",
"acceptsJoins":"litepub:acceptsJoins"
}
],
"type":"Create",
"id":"https://macgirvin.com/activity/ce9ce740-e1cb-4a75-aa4e-9e923555870d",
"published":"2022-02-02T04:41:46Z",
"context":"https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"conversation":"https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"actor":"https://macgirvin.com/channel/mike",
"replyTo":"https://macgirvin.com/channel/mike",
"url":"https://macgirvin.com/activity/ce9ce740-e1cb-4a75-aa4e-9e923555870d",
"object":{
"type":"Note",
"id":"https://macgirvin.com/item/ce9ce740-e1cb-4a75-aa4e-9e923555870d",
"published":"2022-02-02T04:41:46Z",
"attributedTo":"https://macgirvin.com/channel/mike",
"inReplyTo":"https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"context":"https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"conversation":"https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"content":"The Accepts should get through now. Now to figure out why the comments are failing.",
"source":{
"content":"The Accepts should get through now. Now to figure out why the comments are failing.",
"mediaType":"text/x-multicode"
},
"replyTo":"https://macgirvin.com/channel/mike",
"url":"https://macgirvin.com/item/ce9ce740-e1cb-4a75-aa4e-9e923555870d",
"tag":[
{
"type":"Mention",
"href":"https://gleasonator.com/users/macgirvin",
"name":"@macgirvin@gleasonator.com"
},
{
"type":"Mention",
"href":"https://gleasonator.com/users/alex",
"name":"@alex@gleasonator.com"
}
],
"to":[
"https://www.w3.org/ns/activitystreams#Public",
"https://gleasonator.com/users/alex",
"https://gleasonator.com/users/macgirvin"
],
"cc":[
"https://macgirvin.com/followers/mike",
"https://gleasonator.com/users/macgirvin/followers"
]
},
"tag":[
{
"type":"Mention",
"href":"https://gleasonator.com/users/macgirvin",
"name":"@macgirvin@gleasonator.com"
},
{
"type":"Mention",
"href":"https://gleasonator.com/users/alex",
"name":"@alex@gleasonator.com"
}
],
"to":[
"https://www.w3.org/ns/activitystreams#Public",
"https://gleasonator.com/users/alex",
"https://gleasonator.com/users/macgirvin"
],
"cc":[
"https://macgirvin.com/followers/mike",
"https://gleasonator.com/users/macgirvin/followers"
],
"signature":{
"type":"RsaSignature2017",
"nonce":"544080164a412f0592f8257094a870a0177276f4a04cc4410974f5e8fa277a14",
"creator":"https://macgirvin.com/channel/mike",
"created":"2022-02-02T04:41:46Z",
"signatureValue":"BkHEdRkki/DGHctiI6BWyQdn0i9ip+7rFiqqlLgotgQzwA8wzcmyvFIRm8Z+3OqrbzkNyQLCmx4qHvkqWyNrR0eSSJPaBryYvTLpLBz5F5PSpHOI5x4kRGVaI2S1Po+pUMWgchyyQ8ylqdLVHe0FnqId7vFVo9uj4jWydU5wPGlbb5nvnRMQGGyPqzCJ69lopMgCRCUNgbOz6hYVU0Mhqgi9BDjs1crbRLoGexz87tu7FeGEmtyfz8/SBGrDy+X+U3ahykwqd7ggcptsYVu5BY7BfREOLNZE8BwapUCg+QSw9PJv7dLJytdh0kUrzpuAPNbugx7y662FALmHZlxcIC1IVwbPOwEiosDm6wXsOiIyTvnNFcvDre/B1corB2yt5wmO3Cu5jINvp4+aBTheGIKMxBvpJXywpWe6C0VBqfNZSreJtDwp9lHd6D1+L4V6hUCOqiCcqmLT/GI5TOR+EhSpJ02TOkuu+/8hyIfO6ec3uK98y8suyidckbfM60jrbvZh2s/kF9WlDsE9K+Jlyd9Xx3mI5jU+4MXo1MDA57zYpsXw0S+v++rvnOw8CkQr/opVdIRSCG+UB3VRinpgjwW1UQcdAI+fiVaAwqr45MgnIEaQdk13skJUfUl06D9IxKxhu7yNW1tR621w/HN+358qVQWWBoj+1ZhCG3Thjug="
}
}

View File

@ -0,0 +1,35 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://gleasonator.com/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"actor": "https://gleasonator.com/users/macgirvin",
"attachment": [],
"attributedTo": "https://gleasonator.com/users/macgirvin",
"cc": [
"https://gleasonator.com/users/macgirvin/followers"
],
"content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"9v5bmRalQvjOy0ECcC\" href=\"https://gleasonator.com/users/alex\" rel=\"ugc\">@<span>alex</span></a></span> Any idea why my posts are failing? I sent an Accept/Follow from <a href=\"http://macgirvin.com\" rel=\"ugc\">macgirvin.com</a> at 2022-02-02T04:06:01Z and it vanished into space. As do all my comments to you. <br><br>2022-02-02T04:06:01Z:LOG_INFO:d5c4aa7f6a:Queue.php:435:deliver: deliver: queue post returned 200 from <a href=\"https://gleasonator.com/users/macgirvin/inbox\" rel=\"ugc\">https://gleasonator.com/users/macgirvin/inbox</a><br><br>It&#39;s OK if I&#39;m blocked, but if that&#39;s the case, I shouldn&#39;t be able to send a follow to that address should I?",
"context": "https://gleasonator.com/contexts/b7f01f94-bc92-4d89-a085-0ffc211b0e42",
"conversation": "https://gleasonator.com/contexts/b7f01f94-bc92-4d89-a085-0ffc211b0e42",
"id": "https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb",
"published": "2022-02-02T04:14:10.965833Z",
"sensitive": false,
"source": "@alex Any idea why my posts are failing? I sent an Accept/Follow from macgirvin.com at 2022-02-02T04:06:01Z and it vanished into space. As do all my comments to you. \n\n2022-02-02T04:06:01Z:LOG_INFO:d5c4aa7f6a:Queue.php:435:deliver: deliver: queue post returned 200 from https://gleasonator.com/users/macgirvin/inbox\n\nIt's OK if I'm blocked, but if that's the case, I shouldn't be able to send a follow to that address should I?",
"summary": "",
"tag": [
{
"href": "https://gleasonator.com/users/alex",
"name": "@alex",
"type": "Mention"
}
],
"to": [
"https://www.w3.org/ns/activitystreams#Public",
"https://gleasonator.com/users/alex"
],
"type": "Note"
}

View File

@ -0,0 +1,41 @@
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://gleasonator.com/schemas/litepub-0.1.jsonld",
{
"@language": "und"
}
],
"alsoKnownAs": [],
"attachment": [],
"capabilities": {
"acceptsChatMessages": true
},
"discoverable": false,
"endpoints": {
"oauthAuthorizationEndpoint": "https://gleasonator.com/oauth/authorize",
"oauthRegistrationEndpoint": "https://gleasonator.com/api/v1/apps",
"oauthTokenEndpoint": "https://gleasonator.com/oauth/token",
"sharedInbox": "https://gleasonator.com/inbox",
"uploadMedia": "https://gleasonator.com/api/ap/upload_media"
},
"featured": "https://gleasonator.com/users/macgirvin/collections/featured",
"followers": "https://gleasonator.com/users/macgirvin/followers",
"following": "https://gleasonator.com/users/macgirvin/following",
"id": "https://gleasonator.com/users/macgirvin",
"inbox": "https://gleasonator.com/users/macgirvin/inbox",
"manuallyApprovesFollowers": false,
"name": "macgirvin",
"outbox": "https://gleasonator.com/users/macgirvin/outbox",
"preferredUsername": "macgirvin",
"publicKey": {
"id": "https://gleasonator.com/users/macgirvin#main-key",
"owner": "https://gleasonator.com/users/macgirvin",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0AUMgsQu87tLwoJjZfZu\nsj7NV0qt/THdK8aw4Ha2GZfNkwrep99AZ8gmCI+rr+N5vyETAARzG5/Qzr5bNTUx\nsc1fxFemhhi6sxzAv4qZ5AgvWQ4YPFWizSp5ZY1jpPHLOeF2IftMf8CwVI82PtD0\n7m7T6iUYA4vfvMp9LxVrzQA+CAtpsQxAejTGCt37yM9T2mEWqfmJQQHRIQ4brKBL\nI82sNbzk1cbTwCfH7vRNS/l1ND+vaUGGkDKtpRl56BLmt4picYL0avc+8oO7ebpc\n/zUoS8OOi+mpEzjv7TBrSirYEIGvIh3TKHWSPrpHpQTqj9xBQBy+AxXTWahQEO2M\ndQIDAQAB\n-----END PUBLIC KEY-----\n\n"
},
"summary": "",
"tag": [],
"type": "Person",
"url": "https://gleasonator.com/users/macgirvin",
"vcard:bday": null
}

View File

@ -32,4 +32,15 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidatorTest
%{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
end
end
test "a Note from Roadhouse validates" do
insert(:user, ap_id: "https://macgirvin.com/channel/mike")
%{"object" => note} =
"test/fixtures/roadhouse-create-activity.json"
|> File.read!()
|> Jason.decode!()
%{valid?: true} = ArticleNotePageValidator.cast_and_validate(note)
end
end

View File

@ -0,0 +1,59 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidatorTest do
use Pleroma.DataCase, async: true
alias Pleroma.Web.ActivityPub.ObjectValidator
alias Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator
alias Pleroma.Web.ActivityPub.Utils
import Pleroma.Factory
test "a Create/Note from Roadhouse validates" do
insert(:user, ap_id: "https://macgirvin.com/channel/mike")
note_activity =
"test/fixtures/roadhouse-create-activity.json"
|> File.read!()
|> Jason.decode!()
# Build metadata
{:ok, object_data} = ObjectValidator.cast_and_apply(note_activity["object"])
meta = [object_data: ObjectValidator.stringify_keys(object_data)]
%{valid?: true} = CreateGenericValidator.cast_and_validate(note_activity, meta)
end
test "a Create/Note with mismatched context is invalid" do
user = insert(:user)
note = %{
"id" => Utils.generate_object_id(),
"type" => "Note",
"actor" => user.ap_id,
"to" => [user.follower_address],
"cc" => [],
"content" => "Hello world",
"context" => Utils.generate_context_id()
}
note_activity = %{
"id" => Utils.generate_activity_id(),
"type" => "Create",
"actor" => note["actor"],
"to" => note["to"],
"cc" => note["cc"],
"object" => note,
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
"context" => Utils.generate_context_id()
}
# Build metadata
{:ok, object_data} = ObjectValidator.cast_and_apply(note_activity["object"])
meta = [object_data: ObjectValidator.stringify_keys(object_data)]
%{valid?: false} = CreateGenericValidator.cast_and_validate(note_activity, meta)
end
end

View File

@ -107,6 +107,17 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert activity.data["target"] == new_user.ap_id
assert activity.data["type"] == "Move"
end
test "a reply with mismatched context is rejected" do
insert(:user, ap_id: "https://macgirvin.com/channel/mike")
note_activity =
"test/fixtures/roadhouse-create-activity.json"
|> File.read!()
|> Jason.decode!()
assert {:error, _} = Transmogrifier.handle_incoming(note_activity)
end
end
describe "prepare outgoing" do

View File

@ -355,6 +355,7 @@ defmodule Pleroma.Web.AdminAPI.ReportControllerTest do
} = note
end
@tag :erratic
test "it returns reports with notes", %{conn: conn, admin: admin} do
conn = get(conn, "/api/pleroma/admin/reports")

View File

@ -1311,6 +1311,36 @@ defmodule HttpRequestMock do
}}
end
def get("https://gleasonator.com/objects/102eb097-a18b-4cd5-abfc-f952efcb70bb", _, _, _) do
{:ok,
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/tesla_mock/gleasonator-AG3RzWfwEKKrY63qj2.json"),
headers: activitypub_object_headers()
}}
end
def get("https://gleasonator.com/users/macgirvin", _, _, _) do
{:ok,
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/tesla_mock/macgirvin@gleasonator.com.json"),
headers: activitypub_object_headers()
}}
end
def get("https://gleasonator.com/users/macgirvin/collections/featured", _, _, _) do
{:ok,
%Tesla.Env{
status: 200,
body:
File.read!("test/fixtures/users_mock/masto_featured.json")
|> String.replace("{{domain}}", "gleasonator.com")
|> String.replace("{{nickname}}", "macgirvin"),
headers: activitypub_object_headers()
}}
end
def get(url, query, body, headers) do
{:error,
"Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}