Disable automatic private chat room creation (ref #7)

This commit is contained in:
Tulir Asokan
2017-11-24 16:54:51 +02:00
parent a84349da85
commit 3b42b17bb7
+4 -9
View File
@@ -115,15 +115,11 @@ class MatrixUser {
async syncDialogs({ createRooms = true } = {}) { async syncDialogs({ createRooms = true } = {}) {
const dialogs = await this.telegramPuppet.client("messages.getDialogs", {}) const dialogs = await this.telegramPuppet.client("messages.getDialogs", {})
let changed = false let changed = false
for (const dialog of dialogs.chats.concat(dialogs.users)) { for (const dialog of dialogs.chats) {
if (dialog._ === "chatForbidden" || dialog.deactivated) { if (dialog._ === "chatForbidden" || dialog.deactivated) {
continue continue
} }
const peer = new TelegramPeer(dialog._, dialog.id, { const peer = new TelegramPeer(dialog._, dialog.id)
receiverID: dialog._ === "user"
? this.telegramPuppet.userID
: undefined,
})
const portal = await this.app.getPortalByPeer(peer) const portal = await this.app.getPortalByPeer(peer)
if (await portal.updateInfo(this.telegramPuppet, dialog)) { if (await portal.updateInfo(this.telegramPuppet, dialog)) {
changed = true changed = true
@@ -135,9 +131,8 @@ class MatrixUser {
}) })
if (!created) { if (!created) {
// Make sure the user is invited, since the room already exists. // Make sure the user is invited, since the room already exists.
const intent = await (dialog._ === "user"
? this.app.getTelegramUser(peer.id) const intent = this.app.botIntent
: this.app.botIntent)
// FIXME check membership before re-inviting // FIXME check membership before re-inviting
//const membership = intent.getClient().getRoom(roomID).getMember(this.userID).membership //const membership = intent.getClient().getRoom(roomID).getMember(this.userID).membership
//if (membership !== "join") { //if (membership !== "join") {