From: Roger Braun Date: Tue, 30 May 2017 12:26:31 +0000 (+0200) Subject: Shorten names in links. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=c6aa60c829abb7eeff3e0aec0b8b5eb33b8a4947;p=akkoma Shorten names in links. --- diff --git a/lib/pleroma/web/twitter_api/utils.ex b/lib/pleroma/web/twitter_api/utils.ex index 82e3620f2..91dfa191f 100644 --- a/lib/pleroma/web/twitter_api/utils.ex +++ b/lib/pleroma/web/twitter_api/utils.ex @@ -38,7 +38,8 @@ defmodule Pleroma.Web.TwitterAPI.Utils do end) Enum.reduce(mentions, step_one, fn ({match, %User{ap_id: ap_id}, uuid}, text) -> - String.replace(text, uuid, "#{match}") + short_match = String.split(match, "@") |> tl() |> hd() + String.replace(text, uuid, "@#{short_match}") end) end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 4df1aba9e..df1022d6b 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -263,7 +263,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"}) mentions = TwitterAPI.parse_mentions(text) - expected_text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme@archae.me" + expected_text = "@gsimg According to @archaeme, that is @daggsy. Also hello @archaeme" assert Utils.add_user_links(text, mentions) == expected_text end