Skip to content

Commit

Permalink
Add event_id
Browse files Browse the repository at this point in the history
  • Loading branch information
jdauphant authored Sep 23, 2023
1 parent 7f01d6e commit 4200c79
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manage_last_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async def _on_room_leave(
"type": EventTypes.PowerLevels,
"content": power_levels_content,
"state_key": "",
_maybe_get_event_id_dict_for_room_version(event.room_version),
}
)

Expand Down Expand Up @@ -188,9 +189,18 @@ async def _promote_to_admins(
"type": EventTypes.PowerLevels,
"content": new_pl_content,
"state_key": "",
_maybe_get_event_id_dict_for_room_version(event.room_version),
}
)

def _maybe_get_event_id_dict_for_room_version(room_version: RoomVersion) -> dict:
"""If this room version needs it, generate an event id"""
if room_version.event_format != EventFormatVersions.ROOM_V1_V2:
return {}

randomString = random_string(43)
return {"event_id": "!%i:example.com" % (randomString,)} # TODO : replace example.com with homeserver

def _is_local_user(self, user_id: str) -> bool:
"""Checks whether a given user ID belongs to this homeserver, or a remote
Expand Down

0 comments on commit 4200c79

Please sign in to comment.