aboutsummaryrefslogtreecommitdiff
path: root/roomserver/internal/input
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2021-07-13 11:19:21 +0100
committerGitHub <noreply@github.com>2021-07-13 11:19:21 +0100
commitf8ae391a5b7b506bb2f64547b9415fc9bf068913 (patch)
tree86a2aa99322ca19ee5d5bf58e24b1b7ed22dae9c /roomserver/internal/input
parentf6981420734b56280749f2c273bc0f11e49b7ce6 (diff)
Expose more data when outputting output room events (#1916)
* Add more logging for content fields * Fix fields
Diffstat (limited to 'roomserver/internal/input')
-rw-r--r--roomserver/internal/input/input.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/roomserver/internal/input/input.go b/roomserver/internal/input/input.go
index 6bc43c9c..de40e133 100644
--- a/roomserver/internal/input/input.go
+++ b/roomserver/internal/input/input.go
@@ -30,9 +30,16 @@ import (
"github.com/matrix-org/gomatrixserverlib"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
+ "github.com/tidwall/gjson"
"go.uber.org/atomic"
)
+var keyContentFields = map[string]string{
+ "m.room.join_rules": "join_rule",
+ "m.room.history_visibility": "history_visibility",
+ "m.room.member": "membership",
+}
+
type Inputer struct {
DB storage.Database
Producer sarama.SyncProducer
@@ -95,15 +102,27 @@ func (r *Inputer) WriteOutputEvents(roomID string, updates []api.OutputEvent) er
"type": updates[i].Type,
})
if updates[i].NewRoomEvent != nil {
+ eventType := updates[i].NewRoomEvent.Event.Type()
logger = logger.WithFields(log.Fields{
- "event_type": updates[i].NewRoomEvent.Event.Type(),
+ "event_type": eventType,
"event_id": updates[i].NewRoomEvent.Event.EventID(),
"adds_state": len(updates[i].NewRoomEvent.AddsStateEventIDs),
"removes_state": len(updates[i].NewRoomEvent.RemovesStateEventIDs),
"send_as_server": updates[i].NewRoomEvent.SendAsServer,
"sender": updates[i].NewRoomEvent.Event.Sender(),
})
- if updates[i].NewRoomEvent.Event.Type() == "m.room.server_acl" && updates[i].NewRoomEvent.Event.StateKeyEquals("") {
+ if updates[i].NewRoomEvent.Event.StateKey() != nil {
+ logger = logger.WithField("state_key", *updates[i].NewRoomEvent.Event.StateKey())
+ }
+ contentKey := keyContentFields[eventType]
+ if contentKey != "" {
+ value := gjson.GetBytes(updates[i].NewRoomEvent.Event.Content(), contentKey)
+ if value.Exists() {
+ logger = logger.WithField("content_value", value.String())
+ }
+ }
+
+ if eventType == "m.room.server_acl" && updates[i].NewRoomEvent.Event.StateKeyEquals("") {
ev := updates[i].NewRoomEvent.Event.Unwrap()
defer r.ACLs.OnServerACLUpdate(ev)
}