aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-05-05 19:16:25 +0300
committerTulir Asokan <tulir@maunium.net>2020-05-05 19:16:25 +0300
commit9d4fffb259f0809cd9eae1d77e3e80f4335a4b39 (patch)
tree42cee09277028f7e59f3bd439041ba6816522424 /matrix
parent22681875f32fa97f65c9a52e2ee666932706ce95 (diff)
Don't encrypt outgoing reactions
Diffstat (limited to 'matrix')
-rw-r--r--matrix/matrix.go23
1 files changed, 15 insertions, 8 deletions
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 {