mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
crypto,bridgev2: add option to encrypt reactions and replies (#445)
This commit is contained in:
parent
3a2c6ae865
commit
f4434b33c6
6 changed files with 15 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ type EncryptionConfig struct {
|
|||
Require bool `yaml:"require"`
|
||||
Appservice bool `yaml:"appservice"`
|
||||
MSC4190 bool `yaml:"msc4190"`
|
||||
MSC4392 bool `yaml:"msc4392"`
|
||||
SelfSign bool `yaml:"self_sign"`
|
||||
|
||||
PlaintextMentions bool `yaml:"plaintext_mentions"`
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ func doUpgrade(helper up.Helper) {
|
|||
} else {
|
||||
helper.Copy(up.Bool, "encryption", "msc4190")
|
||||
}
|
||||
helper.Copy(up.Bool, "encryption", "msc4392")
|
||||
helper.Copy(up.Bool, "encryption", "self_sign")
|
||||
helper.Copy(up.Bool, "encryption", "allow_key_sharing")
|
||||
if secret, ok := helper.Get(up.Str, "encryption", "pickle_key"); !ok || secret == "generate" {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func (as *ASIntent) SendMessage(ctx context.Context, roomID id.RoomID, eventType
|
|||
Extra: content.Raw,
|
||||
})
|
||||
}
|
||||
if eventType != event.EventReaction && eventType != event.EventRedaction {
|
||||
if (eventType != event.EventReaction || as.Connector.Config.Encryption.MSC4392) && eventType != event.EventRedaction {
|
||||
msgContent, ok := content.Parsed.(*event.MessageEventContent)
|
||||
if ok {
|
||||
msgContent.AddPerMessageProfileFallback()
|
||||
|
|
|
|||
|
|
@ -378,6 +378,8 @@ encryption:
|
|||
# Only relevant when using end-to-bridge encryption, required when using encryption with next-gen auth (MSC3861).
|
||||
# Changing this option requires updating the appservice registration file.
|
||||
msc4190: false
|
||||
# Whether to encrypt reactions and reply metadata as per MSC4392.
|
||||
msc4392: false
|
||||
# Should the bridge bot generate a recovery key and cross-signing keys and verify itself?
|
||||
# Note that without the latest version of MSC4190, this will fail if you reset the bridge database.
|
||||
# The generated recovery key will be saved in the kv_store table under `recovery_key`.
|
||||
|
|
|
|||
|
|
@ -169,6 +169,15 @@ func (mach *OlmMachine) EncryptMegolmEventWithStateKey(ctx context.Context, room
|
|||
SenderKey: mach.account.IdentityKey(),
|
||||
DeviceID: mach.Client.DeviceID,
|
||||
}
|
||||
if mach.MSC4392Relations && encrypted.RelatesTo != nil {
|
||||
// When MSC4392 mode is enabled, reply and reaction metadata is stripped from the unencrypted content.
|
||||
// Other relations like threads are still left unencrypted.
|
||||
encrypted.RelatesTo.InReplyTo = nil
|
||||
encrypted.RelatesTo.IsFallingBack = false
|
||||
if evtType == event.EventReaction || encrypted.RelatesTo.Type == "" {
|
||||
encrypted.RelatesTo = nil
|
||||
}
|
||||
}
|
||||
if mach.PlaintextMentions {
|
||||
encrypted.Mentions = getMentions(content)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ type OlmMachine struct {
|
|||
cancelBackgroundCtx context.CancelFunc
|
||||
|
||||
PlaintextMentions bool
|
||||
MSC4392Relations bool
|
||||
AllowEncryptedState bool
|
||||
|
||||
// Never ask the server for keys automatically as a side effect during Megolm decryption.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue