Skip to content

Commit 7fee968

Browse files
ClearlyClaireGargron
authored andcommitted
Do not fetch preview card for mentioned users (#6934)
1 parent d4cf963 commit 7fee968

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

app/services/fetch_link_card_service.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def call(status)
1717

1818
return if @url.nil? || @status.preview_cards.any?
1919

20-
@url = @url.to_s
20+
@mentions = status.mentions
21+
@url = @url.to_s
2122

2223
RedisLock.acquire(lock_options) do |lock|
2324
if lock.acquired?
@@ -81,9 +82,16 @@ def bad_url?(uri)
8182
uri.host.blank? || TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme)
8283
end
8384

85+
def mention_link?(a)
86+
return false if @mentions.nil?
87+
@mentions.any? do |mention|
88+
a['href'] == TagManager.instance.url_for(mention.target)
89+
end
90+
end
91+
8492
def skip_link?(a)
8593
# Avoid links for hashtags and mentions (microformats)
86-
a['rel']&.include?('tag') || a['class']&.include?('u-url')
94+
a['rel']&.include?('tag') || a['class']&.include?('u-url') || mention_link?(a)
8795
end
8896

8997
def attempt_oembed

0 commit comments

Comments
 (0)