Page MenuHomePhabricator

API to switch between public/private registration [HIGH PRIORITY]
Closed, ResolvedPublic

Description

On our last engineering meeting, we decided that we will use the register/unregister API.

Acceptance criteria

  • Add a new parameter to the register/unregister API , "is_private", if it is true set the registration as private, if false set it as public.
  • Document this parameter on mw.org
  • Given a participant changes its registration from private to public
    • Then we must update the "cep_private" to false on "ce_participants"
  • Given a participant changes its registration from public to private
    • Then we must update the "cep_private" to true on "ce_participants"

Event Timeline

Preliminary note: since the REST API framework does not support PATCH requests, it's probably easier to include it in the existing endpoint.

Preliminary note: since the REST API framework does not support PATCH requests, it's probably easier to include it in the existing endpoint.

Sounds good to me, do we have a ticket for that? If not, we can update this one, and add the acceptance criteria.

I think we can just use this one.

Hi @Daimona and @MHorsey-WMF I updated the acceptance criteria, please let me know what you think.

Daimona updated the task description. (Show Details)

Hi @Daimona and @MHorsey-WMF I updated the acceptance criteria, please let me know what you think.

LGTM, I've reformatted it a bit and removed the part about the parameter not being passed. Since this is a PUT endpoint, the client is required to provide a full representation of the resource, and "private" needs to be part of that representation.

The alternative would be to create a PATCH endpoint, but that's not possible due to the reasons already discussed.

Hi @Daimona and @MHorsey-WMF I updated the acceptance criteria, please let me know what you think.

LGTM, I've reformatted it a bit and removed the part about the parameter not being passed. Since this is a PUT endpoint, the client is required to provide a full representation of the resource, and "private" needs to be part of that representation.

To clarify, I think we could make the parameter optional and still respect the REST specification, but the correct implementation would be:

  • Given the register/unregister API is called and the private parameter is not passed
    • cep_private is set to a default value that is not dependent on the previous state, so always true or always false

Which I don't think is a good idea.

Hi @Daimona and @MHorsey-WMF I updated the acceptance criteria, please let me know what you think.

LGTM, I've reformatted it a bit and removed the part about the parameter not being passed. Since this is a PUT endpoint, the client is required to provide a full representation of the resource, and "private" needs to be part of that representation.

To clarify, I think we could make the parameter optional and still respect the REST specification, but the correct implementation would be:

  • Given the register/unregister API is called and the private parameter is not passed
    • cep_private is set to a default value that is not dependent on the previous state, so always true or always false

Which I don't think is a good idea.

Thanks @Daimona I totally agree.

Change 839633 had a related patch set uploaded (by Mhorsey; author: Mhorsey):

[mediawiki/extensions/CampaignEvents@master] Add support for private registrations

https://gerrit.wikimedia.org/r/839633

@Daimona @cmelo - ESLINT does not like is_private and demands camel case. I have implemented it as such. Thoughts?

@Daimona @cmelo - ESLINT does not like is_private and demands camel case. I have implemented it as such. Thoughts?

eslint is stupid, unfortunately, like all linters... It disallows snake_case in general, and doesn't understand when it's used for API calls. But snake_case is allowed in API parameters, so the eslint warning should be suppressed. There are some examples of that, e.g. here.

Change 839633 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add support for private registrations

https://gerrit.wikimedia.org/r/839633

vyuen changed the task status from Open to In Progress.Oct 31 2022, 4:47 PM

There is overlap between this ticket and T318121, so notes are included there