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
This commit is contained in:
ThibG
2020-03-08 16:10:48 +01:00
committed by GitHub
parent 5e4b649655
commit aa67036b41
4 changed files with 43 additions and 0 deletions

View File

@ -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)