about summary refs log tree commit diff
path: root/app/models/account.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-01-24 14:37:06 +0100
committerThibaut Girka <thib@sitedethib.com>2020-01-24 14:37:06 +0100
commit9adeaf2bfc1c16ca70e611b5288886b21414217b (patch)
tree53372bc9bd6f38d158aad50c768e18773b7d3f3b /app/models/account.rb
parenta8c109baca4d02cc8aed454e231518c1f8ec1844 (diff)
parent4bae4e972d43f71bffb888ac82c180b2fa3f1ada (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/statuses_controller.rb`:
  Minor conflict due to theming system
Diffstat (limited to 'app/models/account.rb')
-rw-r--r--app/models/account.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 9b9361670..b856d1c76 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -478,6 +478,12 @@ class Account < ApplicationRecord
       records
     end
 
+    def from_text(text)
+      return [] if text.blank?
+
+      text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map { |(username, domain)| EntityCache.instance.mention(username, domain) }
+    end
+
     private
 
     def generate_query_for_search(terms)