matrix-commander icon indicating copy to clipboard operation
matrix-commander copied to clipboard

Question: a "delete media" option e.g. for clean-up purposes

Open 8go opened this issue 5 years ago • 7 comments

  • after downloading media to local disk, maybe a "delete" option would be helpful to "clean up" on the server side
  • would be useful for archiving and reducing matrix server db size

8go avatar Oct 31 '20 10:10 8go

Anyone wanting to contribute? Anyone willing to provide a PR? Any contributions are :heart: appreciated!

8go avatar Aug 05 '21 17:08 8go

Which matrix-nio AsyncClient API calls or logic would do such a media delete?

8go avatar Jun 03 '22 15:06 8go

See also:

  • https://github.com/matrix-org/synapse/issues/3479 --> using DB SQL scripts to do cleanup
  • https://github.com/poljar/matrix-nio/issues/308
  • https://git.wehack.space/matrix-synapse-scripts/tree/mxclean
  • https://github.com/mserajnik/synapse-purge --> https://sr.ht/~mser/synupkeep/
  • https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/media_admin_api.md#delete-local-media
  • https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/user_admin_api.md#delete-media-uploaded-by-a-user

HTTP API:

  • curl -XPOST -d '{"msgtype":"m.text", "body":"hello"}' "https://localhost:8448/_matrix/client/r0/rooms/%21asfLdzLnOdGRkdPZWu:localhost/send/m.room.message?access_token=YOUR_ACCESS_TOKEN"

or

curl -XDELETE "https://SERVER_HERE/_synapse/admin/v1/media/SERVER_HERE/XMC_ID_HERE?access_token=ACCESS_TOKEN_HERE" SERVER_HERE something like matrix.org This curl requires ACCESS_TOKEN to have server admin rights (not room admin rights). Otherwise it returns: curl -XDELETE "https://matrix.com/_synapse/admin/v1/media/matrix.com/XMCIDHERE?access_token=ACCESS_TOKEN_HERE" {"errcode":"M_FORBIDDEN","error":"You are not a server admin"}

Building something around this REST API? But obly useable by server admins!

8go avatar Jun 03 '22 17:06 8go

--delete-mxc was implemented in commit 583a2bd

But as required by the Matrix API it requires user to have server admin permissions. See documentation.

Closing issue.

8go avatar Jun 05 '22 08:06 8go

Just wanted to add that I looked at the Client API (not the Admin API) and confirm that there is no "delete" operation for the content repository. So, I think what was implemented was the only available option.

See: Matrix Client API documentation: https://spec.matrix.org/latest/client-server-api

8go avatar Jun 05 '22 08:06 8go

Yes, this is not in the specification. This issue asks to add it to the spec.

The Synapse endpoints may change in the future, because this issue asks for simplification.

Also note that Synapse supports media retention configuration since 1.61 and documented here. It auto-deletes based on the last accessed time and other configurable criteria.

For clarity / posterity, this github issue is about local media, not local copies (cache) of remote media received through federation.

opk12 avatar Sep 12 '22 08:09 opk12

Thank you @opk12 for sharing this very relevant information.

If https://github.com/matrix-org/matrix-spec/issues/226 gets implemented and (ideally) is available via matrix-nio API than it makes a lot of sense to add this new functionality to matrix-commander. I re-open the issue in the hope that there is some future development on the Matrix.org side to advance this issue.

8go avatar Oct 02 '22 13:10 8go