mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Link counter was broken for some https links
This commit is contained in:
@@ -12,10 +12,9 @@ class TopicLinkClick < ActiveRecord::Base
|
|||||||
def self.create_from(args={})
|
def self.create_from(args={})
|
||||||
|
|
||||||
# If the URL is absolute, allow HTTPS and HTTP versions of it
|
# If the URL is absolute, allow HTTPS and HTTP versions of it
|
||||||
|
|
||||||
if args[:url] =~ /^http/
|
if args[:url] =~ /^http/
|
||||||
http_url = args[:url].sub(/^https/, 'http')
|
http_url = args[:url].sub(/^https/, 'http')
|
||||||
https_url = args[:url].sub(/^http/, 'https')
|
https_url = args[:url].sub(/^http\:/, 'https:')
|
||||||
link = TopicLink.select([:id, :user_id]).where('url = ? OR url = ?', http_url, https_url)
|
link = TopicLink.select([:id, :user_id]).where('url = ? OR url = ?', http_url, https_url)
|
||||||
else
|
else
|
||||||
link = TopicLink.select([:id, :user_id]).where(url: args[:url])
|
link = TopicLink.select([:id, :user_id]).where(url: args[:url])
|
||||||
@@ -40,7 +39,6 @@ class TopicLinkClick < ActiveRecord::Base
|
|||||||
|
|
||||||
return args[:url] if (args[:user_id] && (link.user_id == args[:user_id]))
|
return args[:url] if (args[:user_id] && (link.user_id == args[:user_id]))
|
||||||
|
|
||||||
|
|
||||||
# Rate limit the click counts to once in 24 hours
|
# Rate limit the click counts to once in 24 hours
|
||||||
rate_key = "link-clicks:#{link.id}:#{args[:user_id] || args[:ip]}"
|
rate_key = "link-clicks:#{link.id}:#{args[:user_id] || args[:ip]}"
|
||||||
if $redis.setnx(rate_key, "1")
|
if $redis.setnx(rate_key, "1")
|
||||||
|
|||||||
Reference in New Issue
Block a user