From db2e40cac96e67c87593dbf23fb2e09fa0482aea Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 18 Jun 2018 16:29:14 +0100 Subject: [PATCH] Update gomatrixserverlib and use Unsigned AS event prop --- .../storage/appservice_events_table.go | 9 +++++--- vendor/manifest | 2 +- .../gomatrixserverlib/appservice.go | 22 ++++++++++++------- .../gomatrixserverlib/eventcontent.go | 3 +++ .../gomatrixserverlib/federationtypes.go | 6 +++++ 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go b/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go index cbe2cba02..c0a1f296b 100644 --- a/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go +++ b/src/github.com/matrix-org/dendrite/appservice/storage/appservice_events_table.go @@ -174,9 +174,12 @@ func retrieveEvents(eventRows *sql.Rows) (events []gomatrixserverlib.Application maxID = id } - // Get age of the event from original timestamp and current time - // TODO: Consider removing age as not many app services use it - event.Age = nowMilli - event.OriginServerTimestamp + // Portion of the event that is unsigned due to rapid change + event.Unsigned = gomatrixserverlib.ApplicationServiceUnsigned{ + // Get age of the event from original timestamp and current time + // TODO: Consider removing age as not many app services use it + Age: nowMilli - event.OriginServerTimestamp, + } // TODO: Synapse does this. It's unnecessary to send Sender and UserID as the // same value. Do app services really require this? :) diff --git a/vendor/manifest b/vendor/manifest index 2f075ef3e..5694d62a2 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -135,7 +135,7 @@ { "importpath": "github.com/matrix-org/gomatrixserverlib", "repository": "https://github.com/matrix-org/gomatrixserverlib", - "revision": "38a4f0f648bf357adc4bdb601cdc0535cee14e21", + "revision": "4c45af876608399b13cf891e2d9f89f01c67137a", "branch": "master" }, { diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/appservice.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/appservice.go index 18e51b462..211cb9f1c 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/appservice.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/appservice.go @@ -15,17 +15,23 @@ package gomatrixserverlib +// ApplicationServiceUnsigned is the contents of the unsigned field of an +// ApplicationServiceEvent. +type ApplicationServiceUnsigned struct { + Age int64 `json:"age,omitempty"` +} + // ApplicationServiceEvent is an event format that is sent off to an // application service as part of a transaction. type ApplicationServiceEvent struct { - Age int64 `json:"age,omitempty"` - Content RawJSON `json:"content,omitempty"` - EventID string `json:"event_id,omitempty"` - OriginServerTimestamp int64 `json:"origin_server_ts,omitempty"` - RoomID string `json:"room_id,omitempty"` - Sender string `json:"sender,omitempty"` - Type string `json:"type,omitempty"` - UserID string `json:"user_id,omitempty"` + Unsigned ApplicationServiceUnsigned `json:"unsigned,omitempty"` + Content RawJSON `json:"content,omitempty"` + EventID string `json:"event_id,omitempty"` + OriginServerTimestamp int64 `json:"origin_server_ts,omitempty"` + RoomID string `json:"room_id,omitempty"` + Sender string `json:"sender,omitempty"` + Type string `json:"type,omitempty"` + UserID string `json:"user_id,omitempty"` } // ApplicationServiceTransaction is the transaction that is sent off to an diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/eventcontent.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/eventcontent.go index ad4e77513..97b966b67 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/eventcontent.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/eventcontent.go @@ -261,6 +261,9 @@ func newPowerLevelContentFromAuthEvents(authEvents AuthEventProvider, creatorUse // If there is no power level event then the creator gets level 100 // https://github.com/matrix-org/synapse/blob/v0.18.5/synapse/api/auth.py#L569 c.userLevels = map[string]int64{creatorUserID: 100} + // If there is no power level event then the state_default is level 0 + // https://github.com/matrix-org/synapse/blob/v0.18.5/synapse/api/auth.py#L997 + c.stateDefaultLevel = 0 return } diff --git a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go index c2adcc0ca..5d61521bb 100644 --- a/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go +++ b/vendor/src/github.com/matrix-org/gomatrixserverlib/federationtypes.go @@ -37,6 +37,12 @@ type RespState struct { AuthEvents []Event `json:"auth_chain"` } +// A RespEventAuth is the content of a response to GET /_matrix/federation/v1/event_auth/{roomID}/{eventID} +type RespEventAuth struct { + // A list of events needed to authenticate the state events. + AuthEvents []Event `json:"auth_chain"` +} + // Events combines the auth events and the state events and returns // them in an order where every event comes after its auth events. // Each event will only appear once in the output list.