diff options
author | ThibG <thib@sitedethib.com> | 2020-03-08 16:10:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-08 16:10:48 +0100 |
commit | aa67036b41d37935210c8b5094ac20c153a62011 (patch) | |
tree | 27afe119c6d80b7100e2e92d73df40fc3db2dc7c /app/models/status.rb | |
parent | 5e4b6496557b5ef167518dbc6015307158e30ccf (diff) |
Add support for links to statuses in announcements to be opened in web UI (#13212)
* Add support for links to public statuses in announcements to be opened in WebUI * Please CodeClimate
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index 1610da245..8e040f0e6 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -369,6 +369,21 @@ class Status < ApplicationRecord end end + def from_text(text) + return [] if text.blank? + + text.scan(FetchLinkCardService::URL_PATTERN).map(&:first).uniq.map do |url| + status = begin + if TagManager.instance.local_url?(url) + ActivityPub::TagManager.instance.uri_to_resource(url, Status) + else + Status.find_by(uri: url) || Status.find_by(url: url) + end + end + status&.distributable? ? status : nil + end.compact + end + private def timeline_scope(local_only = false) |