Skip to content

Update invite related endpoints #437

@maxceem

Description

@maxceem

This is one of the tasks on the way to complete migration to V5 standards #435

Overview

Our current implementation of invite related endpoints doesn't follow the RESTful style and has a very custom logic. Also, there are some minor peculiarities that blocks us from implementing new features. So in this challenge we would like to update existent endpoints to be more RESTful and support some minor features we need.

Individual requirements

  • All the invite related endpoints have to use the next URL route as a base: /v5/projects/:projectId(\\d+)/invites (currently we have a mix of slightly different routes like /v5/projects/:projectId(\\d+)/members/invite(s)).

POST /v5/projects/:projectId(\\d+)/invites

GET /v5/projects/:projectId(\\d+)/invites

As per Topcoder V5 standard in the GET endpoints, we always read data from the ES first and if no data is found, we fallback to DB.

  • Currently, when request data from ES we use a very specific query which has 2 disadvantages (see code):

    • we must specify the maximum number of invites to return as we use inner hits, but we want to get all of them
    • this specific query is slower than if we just retrieve the whole project by id
    • So we have to replace it with a simple request to get the whole project document from ES. And just get the list of invites from the project document as project.invites. If the project is not found in ES or the list of invites is empty, we should fallback to DB.
  • Currently, only users who can "view" the project may call this endpoint. We should allow ALL logged-in the users to call this endpoint. But, we should filter the results:

    • users who can "view" the project should get the full list of invites as they can do now
    • users who cannot "view" the project but is logged-in should get only invitations for themself. So if invitation has userId OR email of the currently authorized user, we return such invitations.
    • non-logged-in users should get error 401

GET /v5/projects/:projectId(\\d+)/invites/:inviteId(\\d+)

  • Currently, this endpoint doesn't use inviteId and it gets the invite for the user who is calling this endpoint. Instead, it should return an invitation by inviteId.
  • Any user who can "view" project can get an invitation by id.
  • We should get data from ES first, and fallback to DB if invitation with the requested id is not found in ES.

PATCH /v5/projects/:projectId(\\d+)/invites/:inviteId(\\d+)

  • Use PATCH instead of PUT
  • This endpoint should find an invitation to update inviteId instead of userId or email
  • Only status can be updated
  • The rest logic should be kept as it is, like: we should only be able to update invites in status pending or requested and so on.

DELETE /v5/projects/:projectId(\\d+)/invites/:inviteId(\\d+)

  • [Question 2] We don't have such an endpoint and look like we still don't need it as instead of deleting we updated invitations to have the status canceled.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions