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

We need to refactor the event listener in Mjolnir and the ManagedMjolnir #411

Closed
Gnuxie opened this issue Nov 4, 2022 · 0 comments · Fixed by #446
Closed

We need to refactor the event listener in Mjolnir and the ManagedMjolnir #411

Gnuxie opened this issue Nov 4, 2022 · 0 comments · Fixed by #446
Labels
A-Appservice T-Task Refactoring, enabling or disabling functionality, other engineering tasks

Comments

@Gnuxie
Copy link
Contributor

Gnuxie commented Nov 4, 2022

Currently the managed mjolnir is emulating sync by emitting events on the mjolnir's matrix-bot-sdk MatrixClient. This is obviously hacky and will cause problems later on. We also don't have any way to emulate room.join for managed mjolnirs and this is an edge case that must be considered during this refactor.

public async onEvent(request: Request<WeakEvent>) {
// phony sync.
const mxEvent = request.getData();
if (mxEvent['type'] !== undefined) {
this.mjolnir.client.emit('room.event', mxEvent.room_id, mxEvent);
if (mxEvent.type === 'm.room.message') {
this.mjolnir.client.emit('room.message', mxEvent.room_id, mxEvent);
}
// TODO: We need to figure out how to inform the mjolnir of `room.join`.
}
if (mxEvent['type'] === 'm.room.member') {
if (mxEvent['content']['membership'] === 'invite' && mxEvent.state_key === await this.mjolnir.client.getUserId()) {
this.mjolnir.client.emit('room.invite', mxEvent.room_id, mxEvent);
}
}
}

@Gnuxie Gnuxie added T-Task Refactoring, enabling or disabling functionality, other engineering tasks A-Appservice labels Nov 4, 2022
Gnuxie added a commit that referenced this issue Dec 5, 2022
closes #411.

Issue #411 says that we have to be careful about room.join,
but this was before we figured how to make matrix-appservice-bridge
echo events sent by its own intents.
Gnuxie added a commit that referenced this issue Dec 6, 2022
* Refactor Matrix event listener in Mjolnir and ManagedMjolnir.

closes #411.

Issue #411 says that we have to be careful about room.join,
but this was before we figured how to make matrix-appservice-bridge
echo events sent by its own intents.

* Remove MatrixClientListener since it isn't actually needed.

* Protect which config values can be used for ManagedMjolnirs.

* Introduce MatrixSendClient

so listeners aren't accidentally added to a MatrixClient instead
of MatrixEmitter.

* doc

* Move provisioned mjolnir config to src/config.

This just aids maintance so whenever someone goes to change the config
of the bot they will see this and update it.

* doc for matrix intent listener.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Appservice T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant