FIX: Can click on your own links again
This commit is contained in:
parent
385b2fbde2
commit
01a6b45231
|
@ -12,8 +12,7 @@ class TopicLinkClick < ActiveRecord::Base
|
||||||
def self.create_from(args={})
|
def self.create_from(args={})
|
||||||
|
|
||||||
# Find the forum topic link
|
# Find the forum topic link
|
||||||
link = TopicLink.select(:id).where(url: args[:url])
|
link = TopicLink.select([:id, :user_id]).where(url: args[:url])
|
||||||
link = link.where("user_id <> ?", args[:user_id]) if args[:user_id].present?
|
|
||||||
link = link.where(post_id: args[:post_id]) if args[:post_id].present?
|
link = link.where(post_id: args[:post_id]) if args[:post_id].present?
|
||||||
|
|
||||||
# If we don't have a post, just find the first occurance of the link
|
# If we don't have a post, just find the first occurance of the link
|
||||||
|
@ -21,6 +20,8 @@ class TopicLinkClick < ActiveRecord::Base
|
||||||
link = link.first
|
link = link.first
|
||||||
|
|
||||||
return unless link.present?
|
return unless link.present?
|
||||||
|
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]}"
|
||||||
|
|
Loading…
Reference in New Issue