diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/announcement.rb | 4 | ||||
-rw-r--r-- | app/models/status.rb | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/app/models/announcement.rb b/app/models/announcement.rb index d99502f44..f8ac4e09d 100644 --- a/app/models/announcement.rb +++ b/app/models/announcement.rb @@ -48,6 +48,10 @@ class Announcement < ApplicationRecord @mentions ||= Account.from_text(text) end + def statuses + @statuses ||= Status.from_text(text) + end + def tags @tags ||= Tag.find_or_create_by_names(Extractor.extract_hashtags(text)) end 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) |