Skip to content

Add `PATCH` method for `/user/status` REST API

Peter Hegman requested to merge add-patch-request-for-set-status-api into master

What does this MR do and why?

Related to !106723 (merged), #372981 (closed) and https://gitlab.slack.com/archives/C02PF508L/p1670869061302579

In the set status modal we want the Clear status after field to only be set to Never if the user explicitly sets the dropdown to Never. With the current implementation of the “Set user status” API this is not possible because if you don’t pass the clear_status_after param it defaults to nil and therefore makes that field not set. This MR adds a PATCH version of user/status API that ignores omitted params instead of setting them to nil

How to set up and validate locally

  1. Set a user status and clear status after
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" --data "clear_status_after=1_day" --data "emoji=coffee" \
     --data "message=I crave coffee" "https://gitlab.example.com/api/v4/user/status"
  1. Change the status but omit the clear_status_after param
curl --request PATCH --header "PRIVATE-TOKEN: <your_access_token>" --data "emoji=basketball" \
     --data "message=I like basketball" "https://gitlab.example.com/api/v4/user/status"
  1. Get status. clear_status_after should still be set
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/user/status"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Hegman

Merge request reports