2022-05-27 05:15:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserStatusController < ApplicationController
|
|
|
|
requires_login
|
|
|
|
|
2022-11-24 10:16:28 -05:00
|
|
|
def get
|
|
|
|
ensure_feature_enabled
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { render json: UserStatusSerializer.new(current_user.user_status, root: false) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-27 05:15:14 -04:00
|
|
|
def set
|
|
|
|
ensure_feature_enabled
|
2022-06-22 10:15:33 -04:00
|
|
|
description = params.require(:description)
|
|
|
|
emoji = params.require(:emoji)
|
2022-05-27 05:15:14 -04:00
|
|
|
|
2022-07-05 11:12:22 -04:00
|
|
|
current_user.set_status!(description, emoji, params[:ends_at])
|
2022-05-27 05:15:14 -04:00
|
|
|
render json: success_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def clear
|
|
|
|
ensure_feature_enabled
|
|
|
|
current_user.clear_status!
|
|
|
|
render json: success_json
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def ensure_feature_enabled
|
|
|
|
raise ActionController::RoutingError.new("Not Found") if !SiteSetting.enable_user_status
|
|
|
|
end
|
|
|
|
end
|