-
Notifications
You must be signed in to change notification settings - Fork 18
fix: handle federation events for banned/invited users #384
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
Changes from all commits
270c3a0
5565dde
91e5cc4
50be08a
288a7a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -167,12 +167,19 @@ export class EventService { | |||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||
| await this.validateEvent(event); | ||||||||||||||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||
| this.logger.error({ | ||||||||||||||||||||||||||||||||||||||||||||
| msg: 'Event validation failed', | ||||||||||||||||||||||||||||||||||||||||||||
| origin, | ||||||||||||||||||||||||||||||||||||||||||||
| event, | ||||||||||||||||||||||||||||||||||||||||||||
| err, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| if (err instanceof Error && err.name === 'UnknownRoomError' && event.type === 'm.room.member') { | ||||||||||||||||||||||||||||||||||||||||||||
| await this.eventEmitterService.emit('homeserver.matrix.membership.rejected', { | ||||||||||||||||||||||||||||||||||||||||||||
| event, | ||||||||||||||||||||||||||||||||||||||||||||
| reason: err.message, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+170
to
+175
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard the rejection emit path so listener failures don’t abort PDU processing. If 💡 Suggested hardening- if (err instanceof Error && err.name === 'UnknownRoomError' && event.type === 'm.room.member') {
- await this.eventEmitterService.emit('homeserver.matrix.membership.rejected', {
- event,
- reason: err.message,
- });
+ if (err instanceof Error && err.name === 'UnknownRoomError' && event.type === 'm.room.member') {
+ try {
+ await this.eventEmitterService.emit('homeserver.matrix.membership.rejected', {
+ event,
+ reason: err.message,
+ });
+ } catch (emitErr) {
+ this.logger.error({
+ msg: 'Failed to emit membership rejection event',
+ origin,
+ event,
+ err: emitErr,
+ });
+ }
} else {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| this.logger.error({ | ||||||||||||||||||||||||||||||||||||||||||||
| msg: 'Event validation failed', | ||||||||||||||||||||||||||||||||||||||||||||
| origin, | ||||||||||||||||||||||||||||||||||||||||||||
| event, | ||||||||||||||||||||||||||||||||||||||||||||
| err, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -697,8 +697,10 @@ export class StateService { | |
|
|
||
| const servers = new Set<string>(); | ||
|
|
||
| const residentMemberships = new Set(['join', 'invite', 'ban']); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Prompt for AI agents |
||
|
|
||
| for (const event of state.values()) { | ||
| if (!event.isMembershipEvent() || event.getMembership() !== 'join') { | ||
| if (!event.isMembershipEvent() || !residentMemberships.has(event.getMembership() ?? '')) { | ||
| continue; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Do not let membership-rejection handler failures abort PDU processing; guard the emitted hook so validation failures still get skipped.
Prompt for AI agents