Awesome-Technologies / synapse-admin

Admin console for synapse Matrix homeserver
https://awesome-technologies.github.io/synapse-admin/
Apache License 2.0
811 stars 122 forks source link

Feature Wishlist - More API Calls #100

Open PC-Admin opened 3 years ago

PC-Admin commented 3 years ago

Some features from my own moderation tool (https://github.com/PC-Admin/PC-Admins-Synapse-Moderation-Tool/blob/master/modtool.py) that are currently missing from 'Synapse Admin':

list_joined_rooms() [Apparently in progress: #73]

# Example:
# $ curl -kXGET https://matrix.perthchat.org/_synapse/admin/v1/users/@PC-Admin:perthchat.org/joined_rooms?access_token=ACCESS_TOKEN

quarantine_users_media()

# Example:
# $ curl -X POST https://matrix.perthchat.org/_synapse/admin/v1/user/@PC-Admin:perthchat.org/media/quarantine?access_token=ACCESS_TOKEN

list_directory_rooms()

# Example
# $ curl -kXGET https://matrix.perthchat.org/_matrix/client/r0/publicRooms?access_token=ACCESS_TOKEN

remove_rooms_from_directory()

# Example
# $ curl -kX PUT -H 'Content-Type: application/json' -d '{"visibility": "private"}' 'https://matrix.perthchat.org/_matrix/client/r0/directory/list/room/!DwUPBvNapIVecNllgt:perthchat.org?access_token=ACCESS_TOKEN'

list_media_in_room()

# Example
# $ curl -kXGET https://matrix.perthchat.org/_synapse/admin/v1/room/<room_id>/media?access_token=ACCESS_TOKEN

quarantine_media_in_room()

# Example
# $ curl -X POST 'https://matrix.perthchat.org/_synapse/admin/v1/room/!DwUPBvNapIVecNllgt:perthchat.org/media/quarantine?access_token=ACCESS_TOKEN'

purge_room() [Deprecated as of Synapse 1.25.0]

# Example:
# $ curl -X POST -H 'Content-Type: application/json' -d '{"new_room_user_id": "@PC-Admin:perthchat.org","room_name": "VIOLATION ROOM 2","message": "You have been very naughty!","block": true,"purge": true}' 'https://matrix.perthchat.org/_synapse/admin/v1/rooms/!mPfaFTrXqUJsgrldwu:perthchat.org/delete?access_token=ACCESS_TOKEN

Lesser importance would be creating/deleting multiple accounts, maybe even purging the remote media repo:

# Example:
# $ date --date '149 days ago' +%s
# 1589442217
# $ curl -X POST --header "Authorization: Bearer ACCESS_TOKEN" 'https://matrix.perthchat.org/_synapse/admin/v1/purge_media_cache?before_ts=1589439628000'

Writing this as a reminder to myself to write you a couple PR's eventually. :) If anyone else feels inspired by it though that's cool too! Sorry if this isn't the best place to post this.

dklimpel commented 3 years ago

list_joined_rooms()

PR: #73

purge_room()

Merged: https://github.com/Awesome-Technologies/synapse-admin/commit/26b8cea6a5a22aee5b94ed8727c6e0be69ae79e5, https://github.com/Awesome-Technologies/synapse-admin/commit/3d4f45d07078a04f37371b24ea73b6209dbfddc7 But without switch for blocking and send notice purge_room will be deprecated in Synapse 1.25.0: https://github.com/matrix-org/synapse/blob/develop/CHANGES.md

awesome-manuel commented 3 years ago

@PC-Admin can you update what you are still missing?

PC-Admin commented 3 years ago

I believe from the above list i made these are still missing:

quarantine_users_media()

# Example:
# $ curl -X POST https://matrix.perthchat.org/_synapse/admin/v1/user/@PC-Admin:perthchat.org/media/quarantine?access_token=ACCESS_TOKEN

quarantine_media_in_room()

# Example
# $ curl -X POST 'https://matrix.perthchat.org/_synapse/admin/v1/room/!DwUPBvNapIVecNllgt:perthchat.org/media/quarantine?access_token=ACCESS_TOKEN'

This projects been making good progress recently. :)

Edited cheers @dklimpel

dklimpel commented 3 years ago

@PC-Admin please have a look at current version.

list_directory_rooms() remove_rooms_from_directory

was part of #105

Thatoo commented 2 months ago

It would be nice to be able to Purge Remote Media API

Thatoo commented 2 months ago

It would be nice also to include synapse-compress-state and be able to launch this tool time to time form within synapse-admin.