Invite bot when user enables encryption in DM portal

This commit is contained in:
Tulir Asokan 2022-03-11 20:11:27 +02:00
parent 7322f78d56
commit 766e6a5130
3 changed files with 9 additions and 3 deletions

2
go.mod
View file

@ -17,7 +17,7 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
maunium.net/go/mauflag v1.0.0
maunium.net/go/maulogger/v2 v2.3.2
maunium.net/go/mautrix v0.10.12-0.20220308120747-bb3d01a193ff
maunium.net/go/mautrix v0.10.12-0.20220311180848-479ccc5277f5
)
require (

4
go.sum
View file

@ -201,5 +201,5 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.10.12-0.20220308120747-bb3d01a193ff h1:SvGasCyulIN5B/3HJEX6kDYNguQcpvZUB/LtT7D69KE=
maunium.net/go/mautrix v0.10.12-0.20220308120747-bb3d01a193ff/go.mod h1:E2KPhL5RETVq1jof+9Nc+HcwOCGoami3bO9woJzoeek=
maunium.net/go/mautrix v0.10.12-0.20220311180848-479ccc5277f5 h1:BRSllqfMZh4eKVM6mRM9RoA07kvH4+9fXAxMkEdGAcQ=
maunium.net/go/mautrix v0.10.12-0.20220311180848-479ccc5277f5/go.mod h1:E2KPhL5RETVq1jof+9Nc+HcwOCGoami3bO9woJzoeek=

View file

@ -75,6 +75,12 @@ func (mx *MatrixHandler) HandleEncryption(evt *event.Event) {
mx.log.Debugfln("%s enabled encryption in %s", evt.Sender, evt.RoomID)
portal.Encrypted = true
portal.Update()
if portal.IsPrivateChat() {
err := mx.as.BotIntent().EnsureJoined(portal.MXID, appservice.EnsureJoinedParams{BotOverride: portal.MainIntent().Client})
if err != nil {
mx.log.Errorfln("Failed to join bot to %s after encryption was enabled: %v", evt.RoomID, err)
}
}
}
}