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

Can't accept or decline direct message invite #3123

Closed
matrixbot opened this issue Nov 1, 2024 · 10 comments
Closed

Can't accept or decline direct message invite #3123

matrixbot opened this issue Nov 1, 2024 · 10 comments

Comments

@matrixbot
Copy link
Collaborator

This issue was originally created by @wangwillian0 at matrix-org/dendrite#3123.

Trying to accept invite:

level=error msg="Failed to join room" error="1 : InputRoomEvents auth failed: InputRoomEventsResponse: eventauth: "@..." is not allowed to change their membership from "leave" to "join" as join rule "invite" forbids it" room_id="!..." servers="[...]" user_id="@..."

Rejecting invite:

level=error msg="Failed to leave room" error="user "@..." is not joined to the room (membership is "leave")" room_id="!..." user_id="@..."

This happens with rooms created by bridges (mainly discord).

Possibly related: matrix-org/dendrite#1760

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @S7evinK at matrix-org/dendrite#3123 (comment).

matrix-org/dendrite#3231 matrix-org/dendrite#3243
Probably fixed by those, closing for now. If it still happens, happy to re-open.

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

I am still seeing this in EW CI

Error: jsHandle.evaluate: M_FORBIDDEN: MatrixError: [403] InputRoomEventsResponse: eventauth: "@bot_0002:localhost" is not allowed to change their membership from "leave" to "join" as join rule "invite" forbids it (http://localhost:32985/_matrix/client/v3/join/!FGvvdATMs7EDmoBb%3Alocalhost)

This is on a bot's auto accept invites behaviour which looks like this:

image

@S7evinK
Copy link
Contributor

S7evinK commented Jan 7, 2025

@t3chguy Where can I find the logs Dendrite produces in CI? How is the room created, any special initial events or something?

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

I've disabled the test in Dendrite for now but will try get you a Playwright trace including Dendrite logs by end of day

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

trace.zip
https://trace.playwright.dev/

Attachments Tab > dendrite logs

@S7evinK
Copy link
Contributor

S7evinK commented Jan 7, 2025

Right, I think the problem is that the room is created with only a "visibility": "public", which Dendrite does not "translate" to public_chat, which then defaults to a join_rule of invite.
Which is.. Fun.. The spec does not require visibility nor preset in requests to /createRoom, all fields are optional.

joinRuleContent := gomatrixserverlib.JoinRuleContent{
JoinRule: spec.Invite,
}
historyVisibilityContent := gomatrixserverlib.HistoryVisibilityContent{
HistoryVisibility: historyVisibilityShared,
}
if createRequest.PowerLevelContentOverride != nil {
// Merge powerLevelContentOverride fields by unmarshalling it atop the defaults
err = json.Unmarshal(createRequest.PowerLevelContentOverride, &powerLevelContent)
if err != nil {
util.GetLogger(ctx).WithError(err).Error("json.Unmarshal for power_level_content_override failed")
return "", &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: spec.BadJSON("malformed power_level_content_override"),
}
}
}
var guestsCanJoin bool
switch createRequest.StatePreset {
case spec.PresetPrivateChat:
joinRuleContent.JoinRule = spec.Invite
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
guestsCanJoin = true
case spec.PresetTrustedPrivateChat:
joinRuleContent.JoinRule = spec.Invite
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
for _, invitee := range createRequest.InvitedUsers {
powerLevelContent.Users[invitee] = 100
}
guestsCanJoin = true
case spec.PresetPublicChat:
joinRuleContent.JoinRule = spec.Public
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
}

So quick fix for the EW test: Set "preset": "public_chat" when creating the room.

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

The spec does say to use visibility if preset is unspecified.

If unspecified, the server should use the visibility to determine which preset to use. A visibility of public equates to a preset of public_chat and private visibility equates to a preset of private_chat.

https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv3createroom

I will open a new issue for it

@S7evinK
Copy link
Contributor

S7evinK commented Jan 7, 2025

Yep, this is a bug in Dendrite, but also a spec clarity issue (IMO) - what should be set/returned if neither visibility nor preset is set?

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

Created #3488

@t3chguy
Copy link
Member

t3chguy commented Jan 7, 2025

Yep, this is a bug in Dendrite, but also a spec clarity issue (IMO) - what should be set/returned if neither visibility nor preset is set?

Oh for sure there is an undefined case, but the case in the test is defined in the spec

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

No branches or pull requests

3 participants