Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-03 21:08:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-03 21:08:34 +0300
commitcf7d071ff1d52a34d1411d8916f251d589bd6381 (patch)
treed3ca63aba3d1b97964ab9c23d9f2c38884d2d662 /lib/api/users.rb
parent4eef6c2c97b50f2305c561f0e1c6f0e14e661642 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/users.rb')
-rw-r--r--lib/api/users.rb46
1 files changed, 37 insertions, 9 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index d2d45c94291..7b4c9104cd8 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -1020,6 +1020,25 @@ module API
end
end
+ helpers do
+ def set_user_status(include_missing_params:)
+ forbidden! unless can?(current_user, :update_user_status, current_user)
+
+ if ::Users::SetStatusService.new(current_user, declared_params(include_missing: include_missing_params)).execute
+ present current_user.status, with: Entities::UserStatus
+ else
+ render_validation_error!(current_user.status)
+ end
+ end
+
+ params :set_user_status_params do
+ optional :emoji, type: String, desc: "The emoji to set on the status"
+ optional :message, type: String, desc: "The status message to set"
+ optional :availability, type: String, desc: "The availability of user to set"
+ optional :clear_status_after, type: String, desc: "Automatically clear emoji, message and availability fields after a certain time", values: UserStatus::CLEAR_STATUS_QUICK_OPTIONS.keys
+ end
+ end
+
desc "Get the currently authenticated user's SSH keys" do
success Entities::SSHKey
end
@@ -1299,21 +1318,30 @@ module API
desc 'Set the status of the current user' do
success Entities::UserStatus
+ detail 'Any parameters that are not passed will be nullified.'
end
params do
- optional :emoji, type: String, desc: "The emoji to set on the status"
- optional :message, type: String, desc: "The status message to set"
- optional :availability, type: String, desc: "The availability of user to set"
- optional :clear_status_after, type: String, desc: "Automatically clear emoji, message and availability fields after a certain time", values: UserStatus::CLEAR_STATUS_QUICK_OPTIONS.keys
+ use :set_user_status_params
end
put "status", feature_category: :users do
- forbidden! unless can?(current_user, :update_user_status, current_user)
+ set_user_status(include_missing_params: true)
+ end
- if ::Users::SetStatusService.new(current_user, declared_params).execute
- present current_user.status, with: Entities::UserStatus
- else
- render_validation_error!(current_user.status)
+ desc 'Set the status of the current user' do
+ success Entities::UserStatus
+ detail 'Any parameters that are not passed will be ignored.'
+ end
+ params do
+ use :set_user_status_params
+ end
+ patch "status", feature_category: :users do
+ if declared_params(include_missing: false).empty?
+ status :ok
+
+ break
end
+
+ set_user_status(include_missing_params: false)
end
desc 'get the status of the current user' do