mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 19:46:55 +08:00
6357a3ce33
This adds API scope for the user status. This also adds a get method to the user status controller. We didn't need a dedicated method that returns status before because the server returns status with user objects, but I think we need to provide this method for API clients.
34 lines
752 B
Ruby
34 lines
752 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserStatusController < ApplicationController
|
|
requires_login
|
|
|
|
def get
|
|
ensure_feature_enabled
|
|
respond_to do |format|
|
|
format.json { render json: UserStatusSerializer.new(current_user.user_status, root: false) }
|
|
end
|
|
end
|
|
|
|
def set
|
|
ensure_feature_enabled
|
|
description = params.require(:description)
|
|
emoji = params.require(:emoji)
|
|
|
|
current_user.set_status!(description, emoji, params[:ends_at])
|
|
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
|