diff options
author | ThibG <thib@sitedethib.com> | 2018-10-28 20:36:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-28 20:36:55 +0100 |
commit | 7f22ed0fc912ffbd94e0df4e0d40750dae542b97 (patch) | |
tree | 770029d865518400da31e9cdb55fc9c584e5a90b /app/services/fetch_link_card_service.rb | |
parent | ee1f1a2ec97604ed364a5944bd300be0771ba7d7 (diff) | |
parent | b00f60f1d3d5415b5fd536191a7ee183ae910d03 (diff) |
Merge pull request #794 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services/fetch_link_card_service.rb')
-rw-r--r-- | app/services/fetch_link_card_service.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 4169c685b..462e5ee13 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -17,7 +17,8 @@ class FetchLinkCardService < BaseService return if @url.nil? || @status.preview_cards.any? - @url = @url.to_s + @mentions = status.mentions + @url = @url.to_s RedisLock.acquire(lock_options) do |lock| if lock.acquired? @@ -62,6 +63,7 @@ class FetchLinkCardService < BaseService def attach_card @status.preview_cards << @card + Rails.cache.delete(@status) end def parse_urls @@ -81,9 +83,16 @@ class FetchLinkCardService < BaseService uri.host.blank? || TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme) end + def mention_link?(a) + return false if @mentions.nil? + @mentions.any? do |mention| + a['href'] == TagManager.instance.url_for(mention.target) + end + end + def skip_link?(a) # Avoid links for hashtags and mentions (microformats) - a['rel']&.include?('tag') || a['class']&.include?('u-url') + a['rel']&.include?('tag') || a['class']&.include?('u-url') || mention_link?(a) end def attempt_oembed |