matrix-org / matrix-spec

The Matrix protocol specification
Apache License 2.0
197 stars 97 forks source link

Appservices should be able to optionally hook into core homeserver operation #258

Open turt2live opened 7 years ago

turt2live commented 7 years ago

Currently appservices are powerful bots and bridges, supplying matrix with 3rd party network access and extensive in-room utility. This can be further extended by offering new API endpoints for the appservice to (optionally) subscribe to particular details about the homeserver's operation. For example, an appservice could listen for whenever a new user is registered, potentially updating some 3rd party software with the new user information.

This could be done by specifying a series of "meta events" that represent homeserver operation. In the above example, a m.new_user event could be emitted with the user_id of who just signed up. These events should be pushed over a dedicated endpoint to give the appservice the option of tarpitting, modifying, or outright canceling the event. This would open up appservices to being able to provide rate limit functionality, 2 factor authentication, and advanced spam management. All of these could (and have been) baked into the homeserver itself, leaving the operator to make a choice as to which homeserver to go with based on features that should really be plugin-like. This also enables homeservers to opt for a more distributed system, further lowering the strain on resources.

Some of the events that would be nice to listen to would be:

These would probably look a lot like the already-existing event structure, just with different types (m.new_user, m.groups.joined, etc). Homeservers should additionally be able to specify custom events for particular integrations to hook into (org.matrix.synapse.metrics_requested, for example).

turt2live commented 6 years ago

This is still something I'd very much like to have, however for the time being I've proposed https://github.com/matrix-org/synapse/pull/2870 as an alternative. I'm not sure which is actually better in practice, however I'm currently running the PR in production to see how horrible of an idea it is.