From 2c820e10b828ca2a00f94d09127d1234bf001d6b Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Wed, 26 Sep 2018 07:48:34 +0200 Subject: [PATCH] transmogrifier_test: incoming notices with tag not being an array (kroeg) --- test/fixtures/https___puckipedia.com_1jjx-ob5r.json | 1 + test/web/activity_pub/transmogrifier_test.exs | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 test/fixtures/https___puckipedia.com_1jjx-ob5r.json diff --git a/test/fixtures/https___puckipedia.com_1jjx-ob5r.json b/test/fixtures/https___puckipedia.com_1jjx-ob5r.json new file mode 100644 index 000000000..3d7025f55 --- /dev/null +++ b/test/fixtures/https___puckipedia.com_1jjx-ob5r.json @@ -0,0 +1 @@ +{"@context":["https://www.w3.org/ns/activitystreams","https://puckipedia.com/-/context"],"actor":{"endpoints":"https://puckipedia.com/#endpoints","followers":"https://puckipedia.com/followers","following":"https://puckipedia.com/following","icon":{"mediaType":"image/png","type":"Image","url":"https://puckipedia.com/images/avatar.png"},"id":"https://puckipedia.com/","inbox":"https://puckipedia.com/inbox","kroeg:blocks":{"id":"https://puckipedia.com/blocks"},"liked":"https://puckipedia.com/liked","manuallyApprovesFollowers":false,"name":"HACKER TEEN PUCKIPEDIA 👩‍💻","outbox":"https://puckipedia.com/outbox","preferredUsername":"puckipedia","publicKey":{"id":"https://puckipedia.com/#key","owner":"https://puckipedia.com/","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvN05xIcFE0Qgany7Rht4\n0ZI5wu++IT7K5iSqRimBYkpoeHbVcT9RFlW+aWH/QJJW/YgZ7+LMr8AMCrKrwSpS\nCndyrpx4O4lZ3FNRLu7tbklh01rGZfE6R1SFfYBpvMvImc9nYT6iezYDbv6NkHku\no3aVhjql216XlA0OhIrqQme9sAdrLbjbMrTUS8douCTkDOX+JFj1ghHCqdYEMZJI\nOY9kovtgnqyxFLm0RsPGsO1+g/OVojqG+VqHz6O2lceaTVQLlnZ4gOhLVG1tVsA2\nRfXQK+R/VgXncYE+BlQVd/tcdGAz7CDL7PP3rP65gmARnafhGR96cCOi/KzlAXSO\nMwIDAQAB\n-----END PUBLIC KEY-----","type":[]},"summary":"

federated hacker teen
\n[she/they]

","type":"Person","updated":"2017-12-19T16:56:29.7576707+00:00"},"cc":"https://puckipedia.com/followers","id":"https://puckipedia.com/1jjx-ob5r","object":{"attributedTo":"https://puckipedia.com/","cc":"https://puckipedia.com/followers","content":"

spinning up an extra process that just handles the delivery queue to see what happens. The concept of this working is kind of amusing :icon_e_smile:

I should probably add back some code to synchronize state between multiple processes; and add back the pubsub mechanism so live streams of collections can return! Also I should add database transactions back.

","conversation":"https://puckipedia.com/f/conversation/4eae6d6c-d046-4737-9c17-c7a791c7ad77","id":"https://puckipedia.com/1jjx-ob5r/note","likes":"https://puckipedia.com/1jjx-ob5r/note/likes","name":"Kroeg dev thread","published":"2018-09-25T22:35:59.770Z","replies":"https://puckipedia.com/1jjx-ob5r/note/replies","shares":"https://puckipedia.com/1jjx-ob5r/note/shares","tag":{"icon":{"mediaType":"image/png","type":"Image","url":"https://puckipedia.com/forum/images/smilies/icon_e_smile.png"},"id":"https://puckipedia.com/forum/images/smilies/icon_e_smile","name":":icon_e_smile:","type":"Emoji","updated":"2018-09-16T11:11:11.111Z"},"to":"https://www.w3.org/ns/activitystreams#Public","type":"Note"},"published":"2018-09-25T22:35:59.770Z","to":"https://www.w3.org/ns/activitystreams#Public","type":"Create"} \ No newline at end of file diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index afa25bb60..42ce701ca 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -121,6 +121,16 @@ test "it works for incoming notices with to/cc not being an array (kroeg)" do "

henlo from my Psion netBook

message sent from my Psion netBook

" end + test "it works for incoming notices with tag not being an array (kroeg)" do + data = File.read!("test/fixtures/https___puckipedia.com_1jjx-ob5r.json") |> Poison.decode!() + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["object"]["emoji"] == %{ + "icon_e_smile" => "https://puckipedia.com/forum/images/smilies/icon_e_smile.png" + } + end + test "it works for incoming follow requests" do user = insert(:user)