MSC4375: Admin Room Management
This commit is contained in:
3
MSCs.md
3
MSCs.md
@@ -22,13 +22,16 @@ Merged MSCs:
|
||||
|
||||
Non-merged MSCs:
|
||||
|
||||
* [MSC2666: Get rooms in common with another user](https://github.com/matrix-org/matrix-spec-proposals/pull/2666)
|
||||
* [MSC4358: Out-of-room server discovery](https://github.com/matrix-org/matrix-spec-proposals/pull/4358)
|
||||
* [MSC4367: via routes in the published room directory](https://github.com/matrix-org/matrix-spec-proposals/pull/4367)
|
||||
* [MSC4370: Federation endpoint for retrieving current extremities](https://github.com/matrix-org/matrix-spec-proposals/pull/4370)
|
||||
* [MSC4373: Server opt-out of specific EDU types](https://github.com/matrix-org/matrix-spec-proposals/pull/4373)
|
||||
* [MSC4375: Admin Room Management](https://github.com/matrix-org/matrix-spec-proposals/pull/4375)
|
||||
|
||||
|
||||
Room version MSCs:
|
||||
|
||||
* [MSC1759: Room V2](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/1759-rooms-v2.md)
|
||||
* [MSC1659: Room V3](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/1659-event-id-as-hashes.md)
|
||||
* [MSC2002: Room V4](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2002-rooms-v4.md)
|
||||
|
||||
@@ -62,8 +62,11 @@ async def spec_versions():
|
||||
["r0.6.1"] + [f"v1.{i}" for i in range(1, 17)]
|
||||
),
|
||||
"unstable_features": {
|
||||
"uk.half-shot.msc2666.query_mutual_rooms": True,
|
||||
"uk.half-shot.msc2666.mutual_rooms": True,
|
||||
"uk.half-shot.msc2666": True,
|
||||
"uk.timedout.msc4323": True
|
||||
"uk.timedout.msc4323": True,
|
||||
"uk.timedout.msc4375": True,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import vona.globals as globals
|
||||
import vona.config as config
|
||||
|
||||
from vona.federation import (
|
||||
send_join,
|
||||
bullshit,
|
||||
)
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
jsonify,
|
||||
@@ -57,3 +62,91 @@ async def lock(user):
|
||||
return jsonify({"locked": req["locked"]})
|
||||
|
||||
return jsonify({"locked": True})
|
||||
|
||||
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms")
|
||||
@admin.route("/_matrix/client/v1/admin/rooms")
|
||||
async def rooms():
|
||||
return jsonify({
|
||||
"chunk": [
|
||||
f"!qa:{config.server_name}",
|
||||
f"!br:{config.server_name}",
|
||||
f"!3:{config.server_name}",
|
||||
f"!D:{config.server_name}",
|
||||
f"!U:{config.server_name}",
|
||||
f"!f:{config.server_name}",
|
||||
f"!gx:{config.server_name}",
|
||||
f"!hx:{config.server_name}",
|
||||
f"!iy:{config.server_name}",
|
||||
f"!p0:{config.server_name}",
|
||||
f"!jZ:{config.server_name}",
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>")
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>")
|
||||
async def room_state(room):
|
||||
if ":" not in room:
|
||||
return jsonify({
|
||||
"errcode": "M_NOT_FOUND",
|
||||
"error": "Unknown room"
|
||||
}), 404
|
||||
else:
|
||||
if room.split(":")[1] != config.server_name:
|
||||
return jsonify({
|
||||
"errcode": "M_NOT_FOUND",
|
||||
"error": "Unknown room"
|
||||
}), 404
|
||||
|
||||
state = globals.strip_state(
|
||||
send_join(bullshit, room)["state"]
|
||||
)
|
||||
|
||||
return jsonify({
|
||||
"state": [state]
|
||||
})
|
||||
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>/evacuate", methods=["POST"])
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>", methods=["DELETE"])
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>/evacuate", methods=["POST"])
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>", methods=["DELETE"])
|
||||
async def evacuate_room(room):
|
||||
req = request.json
|
||||
|
||||
if (
|
||||
"background" in req
|
||||
and isinstance(req["background"], bool)
|
||||
):
|
||||
background = req["background"]
|
||||
else:
|
||||
background = True
|
||||
|
||||
resp = {
|
||||
"background": background,
|
||||
}
|
||||
|
||||
if not background:
|
||||
resp["removed"] = config.the_funny_number
|
||||
|
||||
return resp
|
||||
|
||||
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>/evacuate/status")
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>/delete/status")
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>/evacuate/status")
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>/delete/status")
|
||||
async def evacuate_status(room):
|
||||
return jsonify({
|
||||
"started_at": globals.time(), # everything all at once always now!!!
|
||||
"total": config.the_funny_number,
|
||||
"evacuated": config.the_funny_number,
|
||||
"failed": config.the_funny_number,
|
||||
})
|
||||
|
||||
|
||||
@admin.route("/_matrix/client/unstable/uk.timedout.msc4375/admin/rooms/<room>/blocked", methods=["PUT"])
|
||||
@admin.route("/_matrix/client/v1/admin/rooms/<room>/blocked", methods=["PUT"])
|
||||
async def block(room):
|
||||
return jsonify({})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import vona.globals as globals
|
||||
import vona.config as config
|
||||
import time
|
||||
|
||||
from flask import (
|
||||
Blueprint,
|
||||
@@ -89,7 +88,7 @@ async def users(group):
|
||||
"attestation": globals.sign_json({
|
||||
"group_id": group,
|
||||
"user_id": f"@vona:{config.server_name}",
|
||||
"valid_until_ms": int(str(time.time() * 1000).split(".")[0])
|
||||
"valid_until_ms": globals.time()
|
||||
})
|
||||
}
|
||||
],
|
||||
|
||||
@@ -335,7 +335,7 @@ async def backfill(room):
|
||||
|
||||
return jsonify({
|
||||
"origin": config.server_name,
|
||||
"origin_server_ts": int(str(time.time() * 1000).split(".")[0]),
|
||||
"origin_server_ts": globals.time(),
|
||||
"pdus": send_join(bullshit, room)["state"]
|
||||
})
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from types import SimpleNamespace
|
||||
from collections import Counter
|
||||
import vona.config as config
|
||||
import nacl.signing
|
||||
import time as ti
|
||||
import hashlib
|
||||
import base64
|
||||
import random
|
||||
@@ -461,3 +462,7 @@ def strip_state(state_events) -> list:
|
||||
new_dict["event_id"] = event_id
|
||||
new_list.append(new_dict)
|
||||
return new_list
|
||||
|
||||
|
||||
def time() -> int:
|
||||
return int(str(ti.time() * 1000).split(".")[0])
|
||||
|
||||
Reference in New Issue
Block a user