diff options
author | Tulir Asokan <tulir@maunium.net> | 2020-05-05 19:16:25 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2020-05-05 19:16:25 +0300 |
commit | 9d4fffb259f0809cd9eae1d77e3e80f4335a4b39 (patch) | |
tree | 42cee09277028f7e59f3bd439041ba6816522424 | |
parent | 22681875f32fa97f65c9a52e2ee666932706ce95 (diff) |
Don't encrypt outgoing reactions
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | matrix/matrix.go | 23 |
3 files changed, 18 insertions, 9 deletions
@@ -21,7 +21,7 @@ require ( golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 gopkg.in/yaml.v2 v2.2.8 - maunium.net/go/mautrix v0.2.0-beta.4.0.20200505153708-a120e7a70f5a + maunium.net/go/mautrix v0.2.0-beta.4.0.20200505161530-e9e56523da93 maunium.net/go/mauview v0.1.0 maunium.net/go/tcell v0.1.0 ) @@ -94,6 +94,8 @@ maunium.net/go/mautrix v0.2.0-beta.4.0.20200429002157-8c3bc8eb8f22 h1:hN7gAmWJqI maunium.net/go/mautrix v0.2.0-beta.4.0.20200429002157-8c3bc8eb8f22/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y= maunium.net/go/mautrix v0.2.0-beta.4.0.20200505153708-a120e7a70f5a h1:5cXujK/NGwGDdllVebkfTfUq/yjfF+lc56Wjjikwl50= maunium.net/go/mautrix v0.2.0-beta.4.0.20200505153708-a120e7a70f5a/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y= +maunium.net/go/mautrix v0.2.0-beta.4.0.20200505161530-e9e56523da93 h1:kaf3m/X4QckuNZZjfUdFpaW4E+FnsqsO7UpKT9Rn+kA= +maunium.net/go/mautrix v0.2.0-beta.4.0.20200505161530-e9e56523da93/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y= maunium.net/go/mauview v0.1.0 h1:x2WdkKI2zdriJuPAB0CKlwmnHGE7W9xfM5z6RgG+IIg= maunium.net/go/mauview v0.1.0/go.mod h1:og9WbzmWe9SNYNyOFlCv8qa9zMcOvG2nzRJ5vYyud9U= maunium.net/go/tcell v0.1.0 h1:XzsEoGCvOw5nac+tlkSLzQcliLYTN4PrtA7ar2ptjSM= diff --git a/matrix/matrix.go b/matrix/matrix.go index fe1aaa5..abbd9c6 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -569,6 +569,10 @@ func (c *Container) HandleEncrypted(source EventSource, mxEvent *event.Event) { c.HandleMessage(source, evt) } +type Relatable interface { + GetRelatesTo() *event.RelatesTo +} + // HandleMessage is the event handler for the m.room.message timeline event. func (c *Container) HandleMessage(source EventSource, mxEvent *event.Event) { room := c.GetOrCreateRoom(mxEvent.RoomID) @@ -579,13 +583,16 @@ func (c *Container) HandleMessage(source EventSource, mxEvent *event.Event) { return } - rel := mxEvent.Content.AsMessage().GetRelatesTo() - if editID := rel.GetReplaceID(); len(editID) > 0 { - c.HandleEdit(room, editID, muksevt.Wrap(mxEvent)) - return - } else if reactionID := rel.GetAnnotationID(); mxEvent.Type == event.EventReaction && len(reactionID) > 0 { - c.HandleReaction(room, reactionID, muksevt.Wrap(mxEvent)) - return + relatable, ok := mxEvent.Content.Parsed.(Relatable) + if ok { + rel := relatable.GetRelatesTo() + if editID := rel.GetReplaceID(); len(editID) > 0 { + c.HandleEdit(room, editID, muksevt.Wrap(mxEvent)) + return + } else if reactionID := rel.GetAnnotationID(); mxEvent.Type == event.EventReaction && len(reactionID) > 0 { + c.HandleReaction(room, reactionID, muksevt.Wrap(mxEvent)) + return + } } events, err := c.history.Append(room, []*event.Event{mxEvent}) @@ -880,7 +887,7 @@ func (c *Container) SendEvent(evt *muksevt.Event) (id.EventID, error) { _, _ = c.client.UserTyping(evt.RoomID, false, 0) c.typing = 0 room := c.GetRoom(evt.RoomID) - if room != nil && room.Encrypted { + if room != nil && room.Encrypted && evt.Type != event.EventReaction { encrypted, err := c.crypto.EncryptMegolmEvent(evt.RoomID, evt.Type, evt.Content) if err != nil { if err != crypto.SessionExpired && err != crypto.SessionNotShared && err != crypto.NoGroupSession { |