Skip to content

Commit daf940a

Browse files
tulirturt2live
authored andcommitted
MSC3316: Add timestamp massaging to the spec (#3316)
* Proposal to add timestamp massaging to the spec Signed-off-by: Tulir Asokan <[email protected]> * Update unstable prefix Signed-off-by: Tulir Asokan <[email protected]>
1 parent 161be7e commit daf940a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Proposal to add timestamp massaging to the spec
2+
Bridges often want to override message timestamps to preserve the timestamps from
3+
the remote network. The spec used to have a concept of [timestamp massaging], but
4+
it was excluded from the release due to not being properly specified. Synapse
5+
still implements it and it is widely used in bridges.
6+
7+
[MSC2716] was originally going to add timestamp massaging to the spec, but it
8+
pivoted to focusing solely on batch sending history. This MSC simply copies the
9+
proposed `ts` query param from the [original MSC2716].
10+
11+
[timestamp massaging]: https://matrix.org/docs/spec/application_service/r0.1.2#timestamp-massaging
12+
[MSC2716]: https://github.com/matrix-org/matrix-doc/pull/2716
13+
[original MSC2716]: https://github.com/matrix-org/matrix-doc/blob/94514392b118dfae8ee6840b13b83d2f8ce8fcfc/proposals/2716-importing-history-into-existing-rooms.md
14+
15+
## Proposal
16+
As per the original version of MSC2716:
17+
18+
> We let the AS API override ('massage') the `origin_server_ts` timestamp
19+
> applied to sent events. We do this by adding a `ts` querystring parameter on
20+
> the `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}`
21+
> and `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
22+
> endpoints, specifying the value to apply to `origin_server_ts` on the event
23+
> (UNIX epoch milliseconds).
24+
>
25+
> We consciously don't support the `ts` parameter on the various helper
26+
> syntactic-sugar APIs like /kick and /ban. If a bridge/bot is smart enough to
27+
> be faking history, it is already in the business of dealing with raw events,
28+
> and should not be using the syntactic sugar APIs.
29+
30+
The spec should also make it clear that the `ts` query param won't affect DAG
31+
ordering, and MSC2716's batch sending should be used when the intention is to
32+
insert history somewhere else than the end of the room.
33+
34+
## Potential issues
35+
None.
36+
37+
## Alternatives
38+
The new MSC2716 could technically be considered an alternative, but it can only
39+
be used for history, while this proposal also supports overriding timestamps of
40+
new messages. In practice, bridges will likely use both: Batch sending for
41+
filling history and timestamp massaging for new messages.
42+
43+
## Security considerations
44+
Timestamps should already be considered untrusted over federation, and
45+
application services are trusted server components, so allowing appservices
46+
to override timestamps does not create any new security considerations.
47+
48+
## Unstable prefix
49+
`org.matrix.msc3316.ts` may be used as the query parameter. However, the `ts`
50+
parameter is already used in production for the `/send` endpoint, which means
51+
the unstable prefix should only be used for the `/state` endpoint.

0 commit comments

Comments
 (0)