Bridge read-only status to Matrix when creating room

This commit is contained in:
Tulir Asokan 2020-08-28 19:56:19 +03:00
parent aa6bdc7818
commit 8bef004a46
3 changed files with 19 additions and 1 deletions

View File

@ -341,7 +341,7 @@ class Portal(DBPortal, BasePortal):
if self.config["bridge.encryption.default"] and self.matrix.e2ee: if self.config["bridge.encryption.default"] and self.matrix.e2ee:
self.encrypted = True self.encrypted = True
initial_state.append({ initial_state.append({
"type": "m.room.encryption", "type": str(EventType.ROOM_ENCRYPTION),
"content": {"algorithm": "m.megolm.v1.aes-sha2"}, "content": {"algorithm": "m.megolm.v1.aes-sha2"},
}) })
if self.is_direct: if self.is_direct:
@ -353,6 +353,20 @@ class Portal(DBPortal, BasePortal):
"type": "m.room.related_groups", "type": "m.room.related_groups",
"content": {"groups": [self.config["appservice.community_id"]]}, "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 # 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. # and the initial backfill finishing wouldn't be bridged before the backfill messages.

View File

@ -41,6 +41,7 @@ class Participant(SerializableAttrs['Participant']):
@dataclass @dataclass
class ChatInfo(ChatListInfo, SerializableAttrs['ChatInfo']): class ChatInfo(ChatListInfo, SerializableAttrs['ChatInfo']):
participants: List[Participant] participants: List[Participant]
readonly: bool
@dataclass @dataclass

View File

@ -181,6 +181,7 @@ export default class MessagesPuppeteer {
* @typedef ChatInfo * @typedef ChatInfo
* @type object * @type object
* @property {[Participant]} participants * @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.click("mw-conversation-menu button")
await this.page.waitForSelector(".mat-menu-panel button.mat-menu-item.details", await this.page.waitForSelector(".mat-menu-panel button.mat-menu-item.details",
{ timeout: 500 }) { 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 // There's a 250ms animation and I don't know how to wait for it properly
await sleep(250) await sleep(250)
await this.page.click(".mat-menu-panel button.mat-menu-item.details") 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") await this.page.click("mws-dialog mat-dialog-actions button.confirm")
return { return {
participants, participants,
readonly,
...await this.page.$eval(this._listItemSelector(id), ...await this.page.$eval(this._listItemSelector(id),
elem => window.__mautrixController.parseChatListItem(elem)), elem => window.__mautrixController.parseChatListItem(elem)),
} }