about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorAndrew <andrewLchronister@gmail.com>2017-12-17 22:33:03 -0800
committerchr <chr@cybre.space>2021-03-01 21:44:23 -0800
commit3a295eb1d730cdc6c7b8cef80dff9c6894fe7308 (patch)
treed846e5c4b745db0965ddf84fa113ce7d5cdc739d /app/lib
parent633d175146d6acaf2cc4bfbfcfdee4c85ef20ed1 (diff)
Hotlink twitter mentions
Differentiate twitter mentions from normal mentions
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/formatter.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 7f217ae9f..e0e5012de 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -267,8 +267,9 @@ class Formatter
 
   def link_to_mention(entity, linkable_accounts)
     acct = entity[:screen_name]
+    username, domain = acct.split('@')
 
-    return link_to_account(acct) unless linkable_accounts
+    return link_to_account(acct) unless linkable_accounts and domain != "twitter.com"
 
     account = linkable_accounts.find { |item| TagManager.instance.same_acct?(item.acct, acct) }
     account ? mention_html(account) : "@#{encode(acct)}"
@@ -277,6 +278,10 @@ class Formatter
   def link_to_account(acct)
     username, domain = acct.split('@')
 
+    if domain == "twitter.com"
+      return mention_twitter_html(username)
+    end
+
     domain  = nil if TagManager.instance.local_domain?(domain)
     account = EntityCache.instance.mention(username, domain)
 
@@ -304,4 +309,8 @@ class Formatter
   def mention_html(account)
     "<span class=\"h-card\"><a href=\"#{encode(ActivityPub::TagManager.instance.url_for(account))}\" class=\"u-url mention\">@<span>#{encode(account.username)}</span></a></span>"
   end
+
+  def mention_twitter_html(username)
+      "<span class=\"h-card\"><a href=\"https://twitter.com/#{username}\" class=\"u-url mention\">@<span>#{username}@twitter.com</span></a></span>"
+  end
 end