Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that /invite will respond with 200 if the user is already invited to the room #1084

Merged
merged 3 commits into from
Jul 4, 2022

Conversation

Half-Shot
Copy link
Contributor

@Half-Shot Half-Shot commented May 25, 2022

Potentially fixes #1083

I believe this might fall within the scope of minor text clarification rather than requiring a full MSC, as it's a behavior that has been in action for a long time (for Synapse at least, and possibly other implementations?). This doesn't seek to correct the response.

Preview: https://pr1084--matrix-spec-previews.netlify.app

@Half-Shot Half-Shot requested a review from a team as a code owner May 25, 2022 08:54
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a changelog entry, and evidence that this is in fact the case please :)

@turt2live
Copy link
Member

@Half-Shot are you able to take a look at this?

@Half-Shot
Copy link
Contributor Author

Half-Shot commented Jun 30, 2022

Yep, let me sort that out.

In terms of proof, Synapse would be my evidence. Synapse has a very complex set of rules around how it manages membership but if we assume that it allows a transition of invite -> invite then the handler code will return a 200 response.

In practice you can test this yourself by doing:

# Create a room, out of band
curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/!your:room/invite --data '{"user_id": "@another:user"}'
# Note the membership of the user is now "invite"
curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/!your:room/members
# The second request returns a 200 response.
curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/!your:room/invite --data '{"user_id": "@another:user"}'

This was true in my testing:

➜  ~ curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/\!HNuxrSCzjoKTvWBIuS:half-shot.uk/invite --data '{"user_id": "@h:half-shot.uk"}'
{

}

➜  ~ curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/\!HNuxrSCzjoKTvWBIuS:half-shot.uk/members
{
    "chunk": [
...
        {
            "content": {
                "membership": "invite"
            },
            "room_id": "!HNuxrSCzjoKTvWBIuS:half-shot.uk",
            "sender": "@Half-Shot:half-shot.uk",
            "state_key": "@h:half-shot.uk",
            "type": "m.room.member",
            "age": 807733
        }
    ]
}

➜  ~ curl -H "Authorization: Bearer $AT" https://chaotic.half-shot.uk/_matrix/client/v3/rooms/\!HNuxrSCzjoKTvWBIuS:half-shot.uk/invite --data '{"user_id": "@h:half-shot.uk"}'
{

}

@Half-Shot Half-Shot changed the title Clarify that /invite will respond with 200 if the user is already in the room Clarify that /invite will respond with 200 if the user is already invited to the room Jun 30, 2022
@Half-Shot Half-Shot requested a review from turt2live June 30, 2022 22:40
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise lgtm

changelogs/client_server/newsfragments/1084.clarification Outdated Show resolved Hide resolved
@turt2live turt2live merged commit cf6544c into matrix-org:main Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify the response body/status of /invite when the user is already invited
2 participants