|
| 1 | +# MSC4301: Event capability negotiation between clients |
| 2 | + |
| 3 | +Matrix allows clients to exchange both built-in and custom events with other clients in rooms. There |
| 4 | +is, however, no way for a client to understand what types of events the other clients in a room are |
| 5 | +able to understand. This is problematic as a compatibility mismatch means that the recipient user |
| 6 | +might only be able to see a fallback representation of an event or, in the worst case, nothing at |
| 7 | +all. At the same time, the sender is left wholly unaware of the recipient's experience. |
| 8 | + |
| 9 | +[MSC4300] partially addresses this problem by enabling clients to communicate the result of |
| 10 | +processing a specific event back to the sender. This lets senders determine after the fact whether |
| 11 | +the events they have sent were understood by other clients or not. |
| 12 | + |
| 13 | +The present proposal goes a step further and introduces a scheme for clients to query whether other |
| 14 | +clients understand an event type *ahead* of actually sending that event. This allows clients to |
| 15 | +efficiently negotiate compatible event types resulting in the best possible experience for all |
| 16 | +participants. |
| 17 | + |
| 18 | +## Proposal |
| 19 | + |
| 20 | +A new room event type `m.request.event_capability` is introduced to request supported event types |
| 21 | +from other clients. These capability requests may be time-sensitive and, in the best case, result in |
| 22 | +a capability response from each participating device. For this reason, the processing status request |
| 23 | +/ response mechanism from [MSC4300] is reused. `m.request.event_capability` has the following |
| 24 | +properties in `content`: |
| 25 | + |
| 26 | +- `m.request.status` (object, required): Generic information about the request as per [MSC4300]. |
| 27 | +- `m.request.event_capability` (object, required): Information about the event capability request. |
| 28 | + - `types` (array, required): A list of event types for which the sender wishes to request support. |
| 29 | + |
| 30 | +``` json5 |
| 31 | +{ |
| 32 | + "type": "m.request.event_capability", |
| 33 | + "event_id": "$1", |
| 34 | + "content": { |
| 35 | + // Properties from MSC4300 |
| 36 | + "m.request.status": { |
| 37 | + "from_device": "RJYKSTBOIE", |
| 38 | + "lifetime": 90_000, // 90s |
| 39 | + }, |
| 40 | + // I'd like to send any of these event types into this room. |
| 41 | + // Which of these do you understand? |
| 42 | + "m.request.event_capability": { |
| 43 | + "types": [ |
| 44 | + "m.pizza.margherita", |
| 45 | + "m.pizza.salami", |
| 46 | + "m.pizza.hawaii" |
| 47 | + ] |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +Recipient clients MAY respond to `m.request.event_capability` within its lifetime with the |
| 54 | +`m.response.status` event from [MSC4300] and the following additional properties in `content`: |
| 55 | + |
| 56 | +- `m.response.event_capability` (object, required): Information about the event capability response |
| 57 | + - `types` (array, required): The subset of event types from `m.request.event_capability` that the |
| 58 | + sending device is able to understand. |
| 59 | + |
| 60 | +``` json5 |
| 61 | +{ |
| 62 | + "type": "m.response.status", |
| 63 | + "content": { |
| 64 | + // Properties from MSC4300 |
| 65 | + "m.response.status": { |
| 66 | + "from_device": "EIOBTSKYJR", |
| 67 | + "status": "success", |
| 68 | + "messages": [{ |
| 69 | + "type": "info", |
| 70 | + "m.text": [{ "body": "Refusing to recognise Hawaii as a Pizza style!" }] |
| 71 | + }] |
| 72 | + }, |
| 73 | + "m.relates_to": { |
| 74 | + "event_id": "$1", |
| 75 | + "rel_type": "m.reference", |
| 76 | + }, |
| 77 | + // These are the event types I understand. |
| 78 | + "m.response.event_capability": { |
| 79 | + "types": [ |
| 80 | + "m.pizza.margherita", |
| 81 | + "m.pizza.salami", |
| 82 | + ] |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +## Potential issues |
| 89 | + |
| 90 | +None. |
| 91 | + |
| 92 | +## Alternatives |
| 93 | + |
| 94 | +Instead of querying event capabilities ad-hoc, clients could statically advertise the types of |
| 95 | +events that they are able to understand, for instance, via profiles or state events in a room. This |
| 96 | +would simplify looking up capabilities but comes with its own technical challenges such as scoping |
| 97 | +profiles to devices and rooms or being able to send state events in a room. |
| 98 | + |
| 99 | +## Security considerations |
| 100 | + |
| 101 | +The concerns and remedies around leaking metadata from [MSC4300] apply to this proposal as well. |
| 102 | + |
| 103 | +## Unstable prefix |
| 104 | + |
| 105 | +While this MSC is not considered stable, `m.request.event_capability` (the event type) and |
| 106 | +`m.response.event_capability` should be referred to as `de.gematik.msc4301.request.event_capability` |
| 107 | +and `de.gematik.msc4301.response.event_capability`, respectively. Properties inherited from |
| 108 | +[MSC4300] have their own prefixing requirements. |
| 109 | + |
| 110 | +## Dependencies |
| 111 | + |
| 112 | +This proposal builds on [MSC4300] which at the time of writing has not yet been accepted into the |
| 113 | +spec. |
| 114 | + |
| 115 | + [MSC4300]: https://github.com/matrix-org/matrix-spec-proposals/pull/4300 |
0 commit comments