Attachment parsing, better magic key fetching.
authorRoger Braun <roger@rogerbraun.net>
Wed, 3 May 2017 12:26:49 +0000 (14:26 +0200)
committerRoger Braun <roger@rogerbraun.net>
Wed, 3 May 2017 12:26:49 +0000 (14:26 +0200)
12 files changed:
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/ostatus/ostatus_controller.ex
lib/pleroma/web/salmon/salmon.ex
lib/pleroma/web/web.ex
lib/pleroma/web/web_finger/web_finger.ex
lib/pleroma/web/websub/websub.ex
test/fixtures/incoming_websub_gnusocial_attachments.xml [new file with mode: 0644]
test/user_test.exs
test/web/ostatus/ostatus_test.exs
test/web/salmon/salmon_test.exs
test/web/web_finger/web_finger_test.exs
test/web/websub/websub_test.exs

index 7aa1ac4acfd8d5882f16ff8d6b1a7339107ee547..f81751a256a4ae0e9089498f1fd39ad7bc89d88c 100644 (file)
@@ -39,6 +39,24 @@ defmodule Pleroma.Web.OStatus do
     {:ok, activities}
   end
 
+  def get_attachments(entry) do
+    :xmerl_xpath.string('/entry/link[@rel="enclosure"]', entry)
+    |> Enum.map(fn (enclosure) ->
+      with href when not is_nil(href) <- string_from_xpath("/link/@href", enclosure),
+           type when not is_nil(type) <- string_from_xpath("/link/@type", enclosure) do
+        %{
+          "type" => "Attachment",
+          "url" => [%{
+                       "type" => "Link",
+                       "mediaType" => type,
+                       "href" => href
+                    }]
+        }
+      end
+    end)
+    |> Enum.filter(&(&1))
+  end
+
   def handle_note(entry, doc \\ nil) do
     content_html = string_from_xpath("/entry/content[1]", entry)
 
@@ -48,6 +66,8 @@ defmodule Pleroma.Web.OStatus do
 
     context = (string_from_xpath("/entry/ostatus:conversation[1]", entry) || "") |> String.trim
 
+    attachments = get_attachments(entry)
+
     context = with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(inReplyTo) do
                 context
               else _e ->
@@ -77,7 +97,8 @@ defmodule Pleroma.Web.OStatus do
       "content" => content_html,
       "published" => date,
       "context" => context,
-      "actor" => actor.ap_id
+      "actor" => actor.ap_id,
+      "attachment" => attachments
     }
 
     object = if inReplyTo do
@@ -124,11 +145,11 @@ defmodule Pleroma.Web.OStatus do
     with {:ok, info} <- gather_user_info(uri) do
       data = %{
         local: false,
-        name: info.name,
-        nickname: info.nickname <> "@" <> info.host,
-        ap_id: info.uri,
+        name: info["name"],
+        nickname: info["nickname"] <> "@" <> info["host"],
+        ap_id: info["uri"],
         info: info,
-        avatar: info.avatar
+        avatar: info["avatar"]
       }
       # TODO: Make remote user changeset
       # SHould enforce fqn nickname
@@ -158,8 +179,8 @@ defmodule Pleroma.Web.OStatus do
 
   def gather_user_info(username) do
     with {:ok, webfinger_data} <- WebFinger.finger(username),
-         {:ok, feed_data} <- Websub.gather_feed_data(webfinger_data.topic) do
-      {:ok, Map.merge(webfinger_data, feed_data) |> Map.put(:fqn, username)}
+         {:ok, feed_data} <- Websub.gather_feed_data(webfinger_data["topic"]) do
+      {:ok, Map.merge(webfinger_data, feed_data) |> Map.put("fqn", username)}
     else e ->
       Logger.debug("Couldn't gather info for #{username}")
       {:error, e}
index c6700ae782e9bb00715c0f95a9775efc4eb95b59..1f2dedd3087069abde8a3ac6cd9e615c9ee81986 100644 (file)
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
 
   def salmon_incoming(conn, params) do
     {:ok, body, _conn} = read_body(conn)
-    magic_key = Pleroma.Web.Salmon.fetch_magic_key(body)
+    {:ok, magic_key} = Pleroma.Web.Salmon.fetch_magic_key(body)
     {:ok, doc} = Pleroma.Web.Salmon.decode_and_validate(magic_key, body)
 
     Pleroma.Web.OStatus.handle_incoming(doc)
index b4f214d4600783947ea7a0aaa86b9853e7037d54..f02cb11dca554bbf370e4b2b2d6eb6cbd7aad562 100644 (file)
@@ -24,16 +24,13 @@ defmodule Pleroma.Web.Salmon do
     [data, type, encoding, alg, sig]
   end
 
-  # TODO rewrite in with-stile
-  # Make it fetch the key from the saved user if there is one
   def fetch_magic_key(salmon) do
-    [data, _, _, _, _] = decode(salmon)
-    doc = XML.parse_document(data)
-    uri = XML.string_from_xpath("/entry/author[1]/uri", doc)
-
-    {:ok, info} = Pleroma.Web.OStatus.gather_user_info(uri)
-
-    info.magic_key
+    with [data, _, _, _, _] <- decode(salmon),
+         doc <- XML.parse_document(data),
+         uri when not is_nil(uri) <- XML.string_from_xpath("/entry/author[1]/uri", doc),
+         {:ok, %{info: %{"magic_key" => magic_key}}} <- Pleroma.Web.OStatus.find_or_make_user(uri) do
+      {:ok, magic_key}
+    end
   end
 
   def decode_and_validate(magickey, salmon) do
index a81e3e6e19bab963922d31accb53629d3b082ec4..ee7ee78e9c1f565cc80d641dee9a31423bfa0e8f 100644 (file)
@@ -61,27 +61,7 @@ defmodule Pleroma.Web do
     apply(__MODULE__, which, [])
   end
 
-  def host do
-    settings = Application.get_env(:pleroma, Pleroma.Web.Endpoint)
-    settings
-    |> Keyword.fetch!(:url)
-    |> Keyword.fetch!(:host)
-  end
-
   def base_url do
-    settings = Application.get_env(:pleroma, Pleroma.Web.Endpoint)
-
-    host = host()
-
-    protocol = settings |> Keyword.fetch!(:protocol)
-
-    port_fragment = with {:ok, protocol_info} <- settings |> Keyword.fetch(String.to_atom(protocol)),
-                         {:ok, port} <- protocol_info |> Keyword.fetch(:port)
-    do
-      ":#{port}"
-    else _e ->
-      ""
-    end
-    "#{protocol}://#{host}#{port_fragment}"
+    Pleroma.Web.Endpoint.url
   end
 end
index d16bdd982de22244a79e3b7619a48ea7556927dc..5fa69c2c825b0179eeabd9bad069dcae87056f54 100644 (file)
@@ -16,7 +16,7 @@ defmodule Pleroma.Web.WebFinger do
   end
 
   def webfinger(resource) do
-    host = Pleroma.Web.host
+    host = Pleroma.Web.Endpoint.host
     regex = ~r/(acct:)?(?<username>\w+)@#{host}/
     with %{"username" => username} <- Regex.named_captures(regex, resource) do
       user = User.get_by_nickname(username)
@@ -37,7 +37,7 @@ defmodule Pleroma.Web.WebFinger do
     {
       :XRD, %{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"},
       [
-        {:Subject, "acct:#{user.nickname}@#{Pleroma.Web.host}"},
+        {:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host}"},
         {:Alias, user.ap_id},
         {:Link, %{rel: "http://schemas.google.com/g/2010#updates-from", type: "application/atom+xml", href: OStatus.feed_path(user)}},
         {:Link, %{rel: "http://webfinger.net/rel/profile-page", type: "text/html", href: user.ap_id}},
@@ -72,10 +72,10 @@ defmodule Pleroma.Web.WebFinger do
     subject = XML.string_from_xpath("//Subject", doc)
     salmon = XML.string_from_xpath(~s{//Link[@rel="salmon"]/@href}, doc)
     data = %{
-      magic_key: magic_key,
-      topic: topic,
-      subject: subject,
-      salmon: salmon
+      "magic_key" => magic_key,
+      "topic" => topic,
+      "subject" => subject,
+      "salmon" => salmon
     }
     {:ok, data}
   end
index 546bfb5a4db9d91594c226052c8ba8e033e88f62..e32fc881782458b0d25fbad5aaa384ed533607c0 100644 (file)
@@ -146,12 +146,12 @@ defmodule Pleroma.Web.Websub do
       avatar = OStatus.make_avatar_object(doc)
 
       {:ok, %{
-        uri: uri,
-        hub: hub,
-        nickname: preferredUsername || name,
-        name: displayName || name,
-        host: URI.parse(uri).host,
-        avatar: avatar
+        "uri" => uri,
+        "hub" => hub,
+        "nickname" => preferredUsername || name,
+        "name" => displayName || name,
+        "host" => URI.parse(uri).host,
+        "avatar" => avatar
       }}
     else e ->
       {:error, e}
diff --git a/test/fixtures/incoming_websub_gnusocial_attachments.xml b/test/fixtures/incoming_websub_gnusocial_attachments.xml
new file mode 100644 (file)
index 0000000..9d331ef
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
+ <generator uri="https://gnu.io/social" version="1.0.2-dev">GNU social</generator>
+ <id>https://social.heldscal.la/api/statuses/user_timeline/23211.atom</id>
+ <title>lambadalambda timeline</title>
+ <subtitle>Updates from lambadalambda on social.heldscal.la!</subtitle>
+ <logo>https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg</logo>
+ <updated>2017-05-02T20:29:35+00:00</updated>
+<author>
+ <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
+ <uri>https://social.heldscal.la/user/23211</uri>
+ <name>lambadalambda</name>
+ <summary>Call me Deacon Blues.</summary>
+ <link rel="alternate" type="text/html" href="https://social.heldscal.la/lambadalambda"/>
+ <link rel="avatar" type="image/jpeg" media:width="236" media:height="236" href="https://social.heldscal.la/avatar/23211-original-20170416114255.jpeg"/>
+ <link rel="avatar" type="image/jpeg" media:width="96" media:height="96" href="https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg"/>
+ <link rel="avatar" type="image/jpeg" media:width="48" media:height="48" href="https://social.heldscal.la/avatar/23211-48-20170416114255.jpeg"/>
+ <link rel="avatar" type="image/jpeg" media:width="24" media:height="24" href="https://social.heldscal.la/avatar/23211-24-20170416114257.jpeg"/>
+ <poco:preferredUsername>lambadalambda</poco:preferredUsername>
+ <poco:displayName>Constance Variable</poco:displayName>
+ <poco:note>Call me Deacon Blues.</poco:note>
+ <poco:address>
+  <poco:formatted>Berlin</poco:formatted>
+ </poco:address>
+ <poco:urls>
+  <poco:type>homepage</poco:type>
+  <poco:value>https://heldscal.la</poco:value>
+  <poco:primary>true</poco:primary>
+ </poco:urls>
+ <followers url="https://social.heldscal.la/lambadalambda/subscribers"></followers>
+ <statusnet:profile_info local_id="23211"></statusnet:profile_info>
+</author>
+ <link href="https://social.heldscal.la/lambadalambda" rel="alternate" type="text/html"/>
+ <link href="https://social.heldscal.la/main/sup" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
+ <link href="https://social.heldscal.la/main/push/hub" rel="hub"/>
+ <link href="https://social.heldscal.la/main/salmon/user/23211" rel="salmon"/>
+ <link href="https://social.heldscal.la/main/salmon/user/23211" rel="http://salmon-protocol.org/ns/salmon-replies"/>
+ <link href="https://social.heldscal.la/main/salmon/user/23211" rel="http://salmon-protocol.org/ns/salmon-mention"/>
+ <link href="https://social.heldscal.la/api/statuses/user_timeline/23211.atom" rel="self" type="application/atom+xml"/>
+<entry>
+ <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
+ <id>tag:social.heldscal.la,2017-05-02:noticeId=2020923:objectType=note</id>
+ <title>New note by lambadalambda</title>
+ <content type="html">Okay gonna stream some cool games!! &lt;a href=&quot;https://social.heldscal.la/file/7ed5ee508e6376a6e3dd581e17e7ed0b7b638147c7e86784bf83abc2641ee3d4.gif&quot; title=&quot;https://social.heldscal.la/file/7ed5ee508e6376a6e3dd581e17e7ed0b7b638147c7e86784bf83abc2641ee3d4.gif&quot; rel=&quot;nofollow external noreferrer&quot; class=&quot;attachment&quot; id=&quot;attachment-423842&quot;&gt;https://social.heldscal.la/attachment/423842&lt;/a&gt; &lt;a href=&quot;https://social.heldscal.la/file/4c209099cadfc5afd3e27a334aa0db96b3a7510dde1603305d68a2707e59a11f.png&quot; title=&quot;https://social.heldscal.la/file/4c209099cadfc5afd3e27a334aa0db96b3a7510dde1603305d68a2707e59a11f.png&quot; rel=&quot;nofollow external noreferrer&quot; class=&quot;attachment&quot; id=&quot;attachment-423843&quot;&gt;https://social.heldscal.la/attachment/423843&lt;/a&gt;</content>
+ <link rel="alternate" type="text/html" href="https://social.heldscal.la/notice/2020923"/>
+ <status_net notice_id="2020923"></status_net>
+ <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
+ <published>2017-05-02T20:29:35+00:00</published>
+ <updated>2017-05-02T20:29:35+00:00</updated>
+ <link rel="ostatus:conversation" href="https://social.heldscal.la/conversation/1038558"/>
+ <ostatus:conversation href="https://social.heldscal.la/conversation/1038558" local_id="1038558" ref="tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=26c7afdcbcf4ebd4">tag:social.heldscal.la,2017-05-02:objectType=thread:nonce=26c7afdcbcf4ebd4</ostatus:conversation>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
+ <link rel="enclosure" href="https://social.heldscal.la/file/7ed5ee508e6376a6e3dd581e17e7ed0b7b638147c7e86784bf83abc2641ee3d4.gif" type="image/gif" length="17283"/>
+ <link rel="enclosure" href="https://social.heldscal.la/file/4c209099cadfc5afd3e27a334aa0db96b3a7510dde1603305d68a2707e59a11f.png" type="image/png" length="6965"/>
+ <link rel="self" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/show/2020923.atom"/>
+ <link rel="edit" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/show/2020923.atom"/>
+ <statusnet:notice_info local_id="2020923" source="Pleroma FE"></statusnet:notice_info>
+</entry>
+</feed>
index 1331ac97177ee1fee6ac0340e08888ba397f57f6..7435e30e08464804ed7ecc6389cadfff5b987462 100644 (file)
@@ -111,5 +111,15 @@ defmodule Pleroma.UserTest do
       assert fetched_user == nil
     end
   end
+
+  test "returns an ap_id for a user" do
+    user = insert(:user)
+    assert User.ap_id(user) == Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :feed_redirect, user.nickname)
+  end
+
+  test "returns an ap_followers link for a user" do
+    user = insert(:user)
+    assert User.ap_followers(user) == Pleroma.Web.Router.Helpers.o_status_url(Pleroma.Web.Endpoint, :feed_redirect, user.nickname) <> "/followers"
+  end
 end
 
index e399528075ec294b0b34bf47cd6d1ede19176640..94a7353378e2d091d3d7d4d69ca90a4fffe82edb 100644 (file)
@@ -33,6 +33,16 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["object"]["content"] == "Will it blend?"
   end
 
+  test "handle incoming notes with attachments - GS, subscription" do
+    incoming = File.read!("test/fixtures/incoming_websub_gnusocial_attachments.xml")
+    {:ok, [activity]} = OStatus.handle_incoming(incoming)
+
+    assert activity.data["type"] == "Create"
+    assert activity.data["object"]["type"] == "Note"
+    assert activity.data["object"]["actor"] == "https://social.heldscal.la/user/23211"
+    assert activity.data["object"]["attachment"] |> length == 2
+  end
+
   test "handle incoming notes - Mastodon, salmon, reply" do
     # It uses the context of the replied to object
     Repo.insert!(%Object{
@@ -118,17 +128,17 @@ defmodule Pleroma.Web.OStatusTest do
       {:ok, data} = OStatus.gather_user_info(user)
 
       expected = %{
-        hub: "https://social.heldscal.la/main/push/hub",
-        magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
-        name: "shp",
-        nickname: "shp",
-        salmon: "https://social.heldscal.la/main/salmon/user/29191",
-        subject: "acct:shp@social.heldscal.la",
-        topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
-        uri: "https://social.heldscal.la/user/29191",
-        host: "social.heldscal.la",
-        fqn: user,
-        avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
+        "hub" => "https://social.heldscal.la/main/push/hub",
+        "magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
+        "name" => "shp",
+        "nickname" => "shp",
+        "salmon" => "https://social.heldscal.la/main/salmon/user/29191",
+        "subject" => "acct:shp@social.heldscal.la",
+        "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
+        "uri" => "https://social.heldscal.la/user/29191",
+        "host" => "social.heldscal.la",
+        "fqn" => user,
+        "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
       }
       assert data == expected
     end
@@ -140,17 +150,17 @@ defmodule Pleroma.Web.OStatusTest do
       {:ok, data} = OStatus.gather_user_info(user)
 
       expected = %{
-        hub: "https://social.heldscal.la/main/push/hub",
-        magic_key: "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
-        name: "shp",
-        nickname: "shp",
-        salmon: "https://social.heldscal.la/main/salmon/user/29191",
-        subject: "https://social.heldscal.la/user/29191",
-        topic: "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
-        uri: "https://social.heldscal.la/user/29191",
-        host: "social.heldscal.la",
-        fqn: user,
-        avatar: %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
+        "hub" => "https://social.heldscal.la/main/push/hub",
+        "magic_key" => "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
+        "name" => "shp",
+        "nickname" => "shp",
+        "salmon" => "https://social.heldscal.la/main/salmon/user/29191",
+        "subject" => "https://social.heldscal.la/user/29191",
+        "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
+        "uri" => "https://social.heldscal.la/user/29191",
+        "host" => "social.heldscal.la",
+        "fqn" => user,
+        "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg", "mediaType" => "image/jpeg", "type" => "Link"}]}
       }
       assert data == expected
     end
index 77dacc1c09ed05a6a7db5f95bc6e3b749d02753f..ed26ccf83af3a3c004653420d90ec42977311a19 100644 (file)
@@ -55,7 +55,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
   test "it gets a magic key" do
     # TODO: Make test local
     salmon = File.read!("test/fixtures/salmon2.xml")
-    key = Salmon.fetch_magic_key(salmon)
+    {:ok, key} = Salmon.fetch_magic_key(salmon)
 
     assert key == "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB"
   end
index b48fdd0aa9939b532d2637b472684dbbf5868370..495d3d50b4c80e558d94b0ae88229048b5101ff3 100644 (file)
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.WebFingerTest do
     test "works for fqns" do
       user = insert(:user)
 
-      {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.host}")
+      {:ok, result} = WebFinger.webfinger("#{user.nickname}@#{Pleroma.Web.Endpoint.host}")
       assert is_binary(result)
     end
 
@@ -37,10 +37,10 @@ defmodule Pleroma.Web.WebFingerTest do
 
       {:ok, data} = WebFinger.finger(user, getter)
 
-      assert data.magic_key == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"
-      assert data.topic == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
-      assert data.subject == "acct:shp@social.heldscal.la"
-      assert data.salmon == "https://social.heldscal.la/main/salmon/user/29191"
+      assert data["magic_key"] == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"
+      assert data["topic"] == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
+      assert data["subject"] == "acct:shp@social.heldscal.la"
+      assert data["salmon"] == "https://social.heldscal.la/main/salmon/user/29191"
     end
   end
 
index 63acb3c435e4b37a228ea61f3da6829aa703063c..065fb250aa8c9de3d2d5a88f6719c74439bf4cc7 100644 (file)
@@ -115,12 +115,12 @@ defmodule Pleroma.Web.WebsubTest do
 
     {:ok, discovered} = Websub.gather_feed_data(topic, getter)
     expected = %{
-      hub: "https://mastodon.social/api/push",
-      uri: "https://mastodon.social/users/lambadalambda",
-      nickname: "lambadalambda",
-      name: "Critical Value",
-      host: "mastodon.social",
-      avatar: %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]}
+      "hub" => "https://mastodon.social/api/push",
+      "uri" => "https://mastodon.social/users/lambadalambda",
+      "nickname" => "lambadalambda",
+      "name" => "Critical Value",
+      "host" => "mastodon.social",
+      "avatar" => %{"type" => "Image", "url" => [%{"href" => "https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif?1492379244", "mediaType" => "image/gif", "type" => "Link"}]}
     }
 
     assert expected == discovered