Update gomatrixserverlib and use Unsigned AS event prop

This commit is contained in:
Andrew Morgan 2018-06-18 16:29:14 +01:00
parent c341415b07
commit db2e40cac9
5 changed files with 30 additions and 12 deletions

View file

@ -174,9 +174,12 @@ func retrieveEvents(eventRows *sql.Rows) (events []gomatrixserverlib.Application
maxID = id maxID = id
} }
// Get age of the event from original timestamp and current time // Portion of the event that is unsigned due to rapid change
// TODO: Consider removing age as not many app services use it event.Unsigned = gomatrixserverlib.ApplicationServiceUnsigned{
event.Age = nowMilli - event.OriginServerTimestamp // 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 // TODO: Synapse does this. It's unnecessary to send Sender and UserID as the
// same value. Do app services really require this? :) // same value. Do app services really require this? :)

2
vendor/manifest vendored
View file

@ -135,7 +135,7 @@
{ {
"importpath": "github.com/matrix-org/gomatrixserverlib", "importpath": "github.com/matrix-org/gomatrixserverlib",
"repository": "https://github.com/matrix-org/gomatrixserverlib", "repository": "https://github.com/matrix-org/gomatrixserverlib",
"revision": "38a4f0f648bf357adc4bdb601cdc0535cee14e21", "revision": "4c45af876608399b13cf891e2d9f89f01c67137a",
"branch": "master" "branch": "master"
}, },
{ {

View file

@ -15,17 +15,23 @@
package gomatrixserverlib 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 // ApplicationServiceEvent is an event format that is sent off to an
// application service as part of a transaction. // application service as part of a transaction.
type ApplicationServiceEvent struct { type ApplicationServiceEvent struct {
Age int64 `json:"age,omitempty"` Unsigned ApplicationServiceUnsigned `json:"unsigned,omitempty"`
Content RawJSON `json:"content,omitempty"` Content RawJSON `json:"content,omitempty"`
EventID string `json:"event_id,omitempty"` EventID string `json:"event_id,omitempty"`
OriginServerTimestamp int64 `json:"origin_server_ts,omitempty"` OriginServerTimestamp int64 `json:"origin_server_ts,omitempty"`
RoomID string `json:"room_id,omitempty"` RoomID string `json:"room_id,omitempty"`
Sender string `json:"sender,omitempty"` Sender string `json:"sender,omitempty"`
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
UserID string `json:"user_id,omitempty"` UserID string `json:"user_id,omitempty"`
} }
// ApplicationServiceTransaction is the transaction that is sent off to an // ApplicationServiceTransaction is the transaction that is sent off to an

View file

@ -261,6 +261,9 @@ func newPowerLevelContentFromAuthEvents(authEvents AuthEventProvider, creatorUse
// If there is no power level event then the creator gets level 100 // 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 // https://github.com/matrix-org/synapse/blob/v0.18.5/synapse/api/auth.py#L569
c.userLevels = map[string]int64{creatorUserID: 100} 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 return
} }

View file

@ -37,6 +37,12 @@ type RespState struct {
AuthEvents []Event `json:"auth_chain"` 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 // Events combines the auth events and the state events and returns
// them in an order where every event comes after its auth events. // them in an order where every event comes after its auth events.
// Each event will only appear once in the output list. // Each event will only appear once in the output list.