2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
class ClicksController < ApplicationController
|
2019-05-07 14:37:43 +08:00
|
|
|
skip_before_action :check_xhr, :preload_json, :verify_authenticity_token
|
2013-02-07 23:45:24 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
def track
|
2019-04-23 17:41:36 +08:00
|
|
|
params.require(%i[url post_id topic_id])
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2019-04-23 17:41:36 +08:00
|
|
|
TopicLinkClick.create_from(
|
|
|
|
url: params[:url],
|
|
|
|
post_id: params[:post_id],
|
|
|
|
topic_id: params[:topic_id],
|
|
|
|
ip: request.remote_ip,
|
|
|
|
user_id: current_user&.id,
|
|
|
|
)
|
2013-06-06 15:14:32 +08:00
|
|
|
|
2019-04-23 17:41:36 +08:00
|
|
|
render json: success_json
|
2013-06-06 15:14:32 +08:00
|
|
|
end
|
2013-02-07 23:45:24 +08:00
|
|
|
end
|