Implement Room V10
This commit is contained in:
1
MSCs.md
1
MSCs.md
@@ -37,3 +37,4 @@ Room version MSCs:
|
||||
* [MSC2998: Room V7](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2998-rooms-v7.md)
|
||||
* [MSC3289: Room V8](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3289-rooms-v8.md)
|
||||
* [MSC3375: Room V9](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3375-room-v9.md)
|
||||
* [MSC3604: Room V10](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3604-rooms-v10.md)
|
||||
|
||||
@@ -199,7 +199,7 @@ def v1_v2(request, room) -> dict:
|
||||
|
||||
remote_join = request.get_json()
|
||||
|
||||
response = {
|
||||
return {
|
||||
"auth_chain": event_chain,
|
||||
"event": remote_join,
|
||||
"members_omitted": False,
|
||||
@@ -207,10 +207,8 @@ def v1_v2(request, room) -> dict:
|
||||
"state": event_chain
|
||||
}
|
||||
|
||||
return response
|
||||
|
||||
|
||||
# Room V3 to V9
|
||||
# Room V3 to V10
|
||||
def v3(request, room) -> dict:
|
||||
initial_response = v1_v2(request, room)
|
||||
state = list(initial_response["state"])
|
||||
@@ -238,6 +236,8 @@ def v3(request, room) -> dict:
|
||||
hash_map["m.room.member"],
|
||||
]
|
||||
events["m.room.power_levels"]["prev_events"] = [hash_map["m.room.member"]]
|
||||
if ver == 10:
|
||||
events["m.room.power_levels"]["content"]["users"][f"@vona:{config.server_name}"] = 100
|
||||
events["m.room.power_levels"] = globals.hash_and_sign_event(events["m.room.power_levels"])
|
||||
hash_map["m.room.power_levels"] = globals.make_ref_hash(events["m.room.power_levels"], ver)
|
||||
|
||||
@@ -273,12 +273,10 @@ def v3(request, room) -> dict:
|
||||
new_state.append(events[event])
|
||||
|
||||
|
||||
resp = {
|
||||
return {
|
||||
"auth_chain": new_state,
|
||||
"event": initial_response["event"],
|
||||
"members_omitted": False,
|
||||
"servers_in_room": [config.server_name],
|
||||
"state": new_state
|
||||
}
|
||||
|
||||
return resp
|
||||
|
||||
@@ -268,7 +268,7 @@ def room_version_from_id(room):
|
||||
)
|
||||
hexadecimal_room_id = bytes(room_id_no_sigil, "utf-8").hex()
|
||||
|
||||
versions = [str(i) for i in range(1, 10)]
|
||||
versions = [str(i) for i in range(0, 10)]
|
||||
|
||||
if not any(ver in hexadecimal_room_id for ver in versions):
|
||||
hexadecimal_room_id = "2" + hexadecimal_room_id[1:]
|
||||
@@ -282,7 +282,11 @@ def room_version_from_id(room):
|
||||
s = s.replace(" ", "").lower()
|
||||
counts = Counter(s)
|
||||
most_common = counts.most_common(1)
|
||||
return most_common[0] if most_common else ("2",)
|
||||
|
||||
actual_most_common = most_common[0] if most_common else ("4",)
|
||||
if actual_most_common[0] == "0":
|
||||
return ("10",)
|
||||
return actual_most_common
|
||||
|
||||
return str(most_common_character(nums)[0])
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import vona.globals as globals
|
||||
import vona.config as config
|
||||
import multiprocessing
|
||||
|
||||
versions = [str(i) for i in range(1, 10)]
|
||||
desired_ver = input("Desired room version:\n\t")
|
||||
|
||||
if desired_ver == "10":
|
||||
print(f"!p0:{config.server_name}")
|
||||
exit(0)
|
||||
|
||||
if desired_ver not in versions:
|
||||
print("Unsupported room version")
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user