2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
class UserCalloutsController < ApplicationController
|
|
|
|
def create
|
2020-03-09 13:42:32 +05:30
|
|
|
callout = ensure_callout
|
|
|
|
|
|
|
|
if callout.persisted?
|
|
|
|
callout.update(dismissed_at: Time.now)
|
2018-03-17 18:26:18 +05:30
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :ok }
|
|
|
|
end
|
|
|
|
else
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :bad_request }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
def ensure_callout
|
|
|
|
current_user.callouts.find_or_create_by(feature_name: UserCallout.feature_names[feature_name])
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def feature_name
|
|
|
|
params.require(:feature_name)
|
|
|
|
end
|
|
|
|
end
|