@@ -9,7 +9,9 @@ should purge old messages for a given room.
9
9
It originally also specified how media for purged events should be purged from
10
10
disk, however this was split out into a new MSC [ by
11
11
request] ( https://github.com/matrix-org/matrix-doc/pull/1763#discussion_r320289119 )
12
- during review.
12
+ during review. This proposal also solves
13
+ https://github.com/vector-im/riot-meta/issues/168 - the ability to garbage
14
+ collect attachments from redacted events.
13
15
14
16
## Proposal
15
17
@@ -21,25 +23,30 @@ propose:
21
23
```
22
24
DELETE /_matrix/media/r0/download/{serverName}/{mediaId}
23
25
```
24
- with a JSON dict as a request body.
25
26
26
27
The API would return:
27
28
* ` 200 OK {} ` on success
28
29
* ` 403 ` with error ` M_FORBIDDEN ` if invalid access_token or not authorised to delete.
29
30
* ` 404 ` with error ` M_NOT_FOUND ` if the content described in the URL does not exist on the local server.
30
31
31
32
The user must be authenticated via access_token or Authorization header as the
32
- original uploader, or however the server sees fit in order to delete the content .
33
+ original uploader, or server admin (as determined by the server implementation) .
33
34
34
35
Servers may wish to quarantine the deleted content for some timeframe before
35
36
actually purging it from storage, in order to mitigate abuse.
36
37
37
- XXX: We might want to provide an undelete API too to let users rescue
38
- their content that they accidentally deleted, as you would get on a
39
- typical desktop OS file manager. Perhaps `DELETE` with `{ undo: true }`?
38
+ If ` serverName ` is not the local server, the local cache (if any) of the content
39
+ should be deleted. This proposal makes no effort to delete the remote content.
40
40
41
- XXX: We might also want to let admins quarantine rather than delete attachments
42
- without a timelimit by passing `{ quarantine: true }` or similar.
41
+ Overlapping or near-overlapping authorised requests to ` DELETE ` for existing
42
+ content may either return 200 or 404 based on implementation choice.
43
+
44
+ * XXX: We might want to provide an undelete API too to let users rescue
45
+ their content that they accidentally deleted, as you would get on a
46
+ typical desktop OS file manager. Perhaps ` DELETE ` with ` ?undo=true ` ?*
47
+
48
+ * XXX: We might also want to let admins quarantine rather than delete attachments
49
+ without a timelimit by passing ` ?quarantine=true ` or similar.*
43
50
44
51
Server admins may choose to mark some content as undeletable in their
45
52
implementation (e.g. for sticker packs and other content which should never be
@@ -58,17 +65,19 @@ only one referring event, and so when a client deems that the event should
58
65
be deleted, it is safe to also delete the attachment without breaking any
59
66
other events.
60
67
61
- It seems reasonable to consider the special case of forwarding encrypted
62
- attachments between rooms as a 'copy by reference' - if the original
63
- event gets deleted, the others should too. If this isn't desired, then
64
- the attachment should be reencrypted.
68
+ It seems reasonable to consider the special case of clients forwarding
69
+ encrypted attachments between rooms as a 'copy by reference' - if the
70
+ original event gets deleted, the copies should too. If this isn't desired,
71
+ then the attachment should have been reencrypted and stored as a separate
72
+ instance in the media repo.
65
73
66
74
### Unencrypted rooms
67
75
68
- It's common for MXC URLs to be shared between unencrypted events - e.g. reusing
69
- sticker media, or when forwarding messages between rooms, etc. In this instance,
70
- the homeserver (not media server) should count the references to a given MXC URL
71
- by events which refer to it.
76
+ It's common for MXC URLs to be shared between unencrypted events - e.g.
77
+ reusing sticker media, or when forwarding messages between rooms, etc. In
78
+ this instance, the homeserver (not media server) should count the references
79
+ to a given MXC URL by events which refer to it (including state events such as
80
+ avatar URLs in ` m.room.membership ` events.)
72
81
73
82
If all events which refer to it have been purged or redacted, the HS should delete
74
83
the attachment - either by internally deleting the media, or if using an
@@ -93,6 +102,20 @@ being referenced in multiple rooms), but the room admin may want to still
93
102
purge the content from their server. This can be achieved by DELETEing the
94
103
content independently from redacting the membership events.
95
104
105
+ * N.B. we can't currently distinguish an E2EE attachment with unknown refering
106
+ events, from a non-E2EE attachment with zero references which should be GCd.
107
+ So we use mime-types as a heuristic to recognise E2EE attachments, and to stop
108
+ them from being GC'd This would of course be vulnerable to an attacker lying
109
+ about their mime-type in order to stop their repository entries being GC'd,
110
+ but given E2EE attachments already let you bypass the GC, this doesn't feel
111
+ like a big issue.*
112
+
113
+ Encrypted attachments should be stored with a mime-type of
114
+ ` application/aes-encrypted ` (to be registered), and attachments
115
+ with this mime-type which have never been referenced by an event should
116
+ be exempt from GC. For backwards compatibility, this rule may also be
117
+ applied to attachments with mime-type of ` application/octet-stream ` .
118
+
96
119
## Tradeoffs
97
120
98
121
Assuming that encrypted events don't reuse attachments is controversial but
0 commit comments