Save remote users with fqn as nickname.
authorRoger Braun <roger@rogerbraun.net>
Sat, 29 Apr 2017 18:08:45 +0000 (20:08 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sat, 29 Apr 2017 18:08:45 +0000 (20:08 +0200)
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/websub/websub.ex
test/web/ostatus/ostatus_test.exs
test/web/websub/websub_test.exs

index 3e239179e502bd5f5c72f7a82bdb0849cd722ec0..59c5d8e9e177d02fd4a32f77b6ed81f93abf2e72 100644 (file)
@@ -96,10 +96,12 @@ defmodule Pleroma.Web.OStatus do
       data = %{
         local: false,
         name: info.name,
-        nickname: info.nickname,
+        nickname: info.nickname <> "@" <> info.host,
         ap_id: info.uri,
         info: info
       }
+      # TODO: Make remote user changeset
+      # SHould enforce fqn nickname
       Repo.insert(Ecto.Changeset.change(%User{}, data))
     end
   end
index 8e3e0a54e23ccecd1b68b2147851b412eb02baae..3fd779fba25c50956f09c7be51e59f990c162903 100644 (file)
@@ -139,7 +139,8 @@ defmodule Pleroma.Web.Websub do
         uri: uri,
         hub: hub,
         nickname: preferredUsername || name,
-        name: displayName || name
+        name: displayName || name,
+        host: URI.parse(uri).host
       }}
     else e ->
       {:error, e}
index 4f396d9409ea4b2b5cfe146ce4c409a816d77b67..cc0975bb595a4a3d8883488474211b086919c5cf 100644 (file)
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.OStatusTest do
 
       user = Repo.get(Pleroma.User, user.id)
       assert user.name == "Constance Variable"
-      assert user.nickname == "lambadalambda"
+      assert user.nickname == "lambadalambda@social.heldscal.la"
       assert user.local == false
       assert user.info["uri"] == uri
       assert user.ap_id == uri
@@ -60,6 +60,7 @@ defmodule Pleroma.Web.OStatusTest do
         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
       }
       assert data == expected
@@ -80,6 +81,7 @@ defmodule Pleroma.Web.OStatusTest do
         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
       }
       assert data == expected
index 25c2b8baae6068d1e0690621aa18cab4570a7807..e0d71e16d96d72928eadbdcfd8478bef99d09d3a 100644 (file)
@@ -118,7 +118,8 @@ defmodule Pleroma.Web.WebsubTest do
       hub: "https://mastodon.social/api/push",
       uri: "https://mastodon.social/users/lambadalambda",
       nickname: "lambadalambda",
-      name: "Critical Value"
+      name: "Critical Value",
+      host: "mastodon.social"
     }
 
     assert expected == discovered