From 766e6a513007803f2be4fcbb587297763bd8fa75 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 11 Mar 2022 20:11:27 +0200 Subject: [PATCH] Invite bot when user enables encryption in DM portal --- go.mod | 2 +- go.sum | 4 ++-- matrix.go | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 01e9a18..8f2a162 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index 1208e08..af07327 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/matrix.go b/matrix.go index e8c9657..408d19a 100644 --- a/matrix.go +++ b/matrix.go @@ -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) + } + } } }