MastoAPI: Remove domain ending from account name.
authorRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 07:34:39 +0000 (09:34 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 12 Sep 2017 07:34:39 +0000 (09:34 +0200)
lib/pleroma/web/mastodon_api/views/account_view.ex
test/web/mastodon_api/account_view_test.exs

index 35a130b1edba6ef57e5389841101289e00d1ecfe..85cce754a7859865126a5f5ceaa4026cc4969448 100644 (file)
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
     %{
       id: user.id,
-      username: user.nickname,
+      username: hd(String.split(user.nickname, "@")),
       acct: user.nickname,
       display_name: user.name,
       locked: false,
@@ -34,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
     %{
       id: user.id,
       acct: user.nickname,
-      username: user.nickname,
+      username: hd(String.split(user.nickname, "@")),
       url: user.ap_id
     }
   end
index 59fac6d95bd2453280eb4c370f31f546a711205c..0106fbcc0f5c43797ba71a95a1db56cc88ea536f 100644 (file)
@@ -4,11 +4,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
   alias Pleroma.Web.MastodonAPI.AccountView
 
   test "Represent a user account" do
-    user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}})
+    user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}, nickname: "shp@shitposter.club"})
 
     expected = %{
       id: user.id,
-      username: user.nickname,
+      username: "shp",
       acct: user.nickname,
       display_name: user.name,
       locked: false,