FIX: TopicLinkClick: do not log IP of logged in users
This commit is contained in:
parent
24abf38d38
commit
9b0efe9c84
|
@ -7,7 +7,6 @@ class TopicLinkClick < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
|
||||
validates_presence_of :topic_link_id
|
||||
validates_presence_of :ip_address
|
||||
|
||||
WHITELISTED_REDIRECT_HOSTNAMES = Set.new(%W{www.youtube.com youtu.be})
|
||||
|
||||
|
@ -108,6 +107,7 @@ class TopicLinkClick < ActiveRecord::Base
|
|||
rate_key = "link-clicks:#{link.id}:#{args[:user_id] || args[:ip]}"
|
||||
if $redis.setnx(rate_key, "1")
|
||||
$redis.expire(rate_key, 1.day.to_i)
|
||||
args[:ip] = nil if args[:user_id]
|
||||
create!(topic_link_id: link.id, user_id: args[:user_id], ip_address: args[:ip])
|
||||
end
|
||||
|
||||
|
@ -125,7 +125,7 @@ end
|
|||
# user_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ip_address :inet not null
|
||||
# ip_address :inet
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
class AllowNullIpTopicLinkClick < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
begin
|
||||
Migration::SafeMigrate.disable!
|
||||
change_column :topic_link_clicks, :ip_address, :inet, null: true
|
||||
ensure
|
||||
Migration::SafeMigrate.enable!
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue