diff --git a/mautrix_amp/portal.py b/mautrix_amp/portal.py index 0d61c08..107f39a 100644 --- a/mautrix_amp/portal.py +++ b/mautrix_amp/portal.py @@ -341,7 +341,7 @@ class Portal(DBPortal, BasePortal): if self.config["bridge.encryption.default"] and self.matrix.e2ee: self.encrypted = True initial_state.append({ - "type": "m.room.encryption", + "type": str(EventType.ROOM_ENCRYPTION), "content": {"algorithm": "m.megolm.v1.aes-sha2"}, }) if self.is_direct: @@ -353,6 +353,20 @@ class Portal(DBPortal, BasePortal): "type": "m.room.related_groups", "content": {"groups": [self.config["appservice.community_id"]]}, }) + initial_state.append({ + "type": str(EventType.ROOM_POWER_LEVELS), + "content": { + "users": { + self.az.bot_mxid: 100, + self.main_intent.mxid: 9001, + }, + "events": {}, + "events_default": 100 if info.readonly else 0, + "state_default": 50, + "invite": 50, + "redact": 0 + } + }) # We lock backfill lock here so any messages that come between the room being created # and the initial backfill finishing wouldn't be bridged before the backfill messages. diff --git a/mautrix_amp/rpc/types.py b/mautrix_amp/rpc/types.py index d7941f2..cf8138a 100644 --- a/mautrix_amp/rpc/types.py +++ b/mautrix_amp/rpc/types.py @@ -41,6 +41,7 @@ class Participant(SerializableAttrs['Participant']): @dataclass class ChatInfo(ChatListInfo, SerializableAttrs['ChatInfo']): participants: List[Participant] + readonly: bool @dataclass diff --git a/puppet/src/puppet.js b/puppet/src/puppet.js index 033b624..e138ade 100644 --- a/puppet/src/puppet.js +++ b/puppet/src/puppet.js @@ -181,6 +181,7 @@ export default class MessagesPuppeteer { * @typedef ChatInfo * @type object * @property {[Participant]} participants + * @property {boolean} readonly */ /** @@ -256,6 +257,7 @@ export default class MessagesPuppeteer { await this.page.click("mw-conversation-menu button") await this.page.waitForSelector(".mat-menu-panel button.mat-menu-item.details", { timeout: 500 }) + const readonly = await this.page.$("mw-conversation-container .compose-readonly") !== null // There's a 250ms animation and I don't know how to wait for it properly await sleep(250) await this.page.click(".mat-menu-panel button.mat-menu-item.details") @@ -267,6 +269,7 @@ export default class MessagesPuppeteer { await this.page.click("mws-dialog mat-dialog-actions button.confirm") return { participants, + readonly, ...await this.page.$eval(this._listItemSelector(id), elem => window.__mautrixController.parseChatListItem(elem)), }