From da858d6b6541835892dd650f706aaf5396f606f9 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 28 Jun 2017 14:02:13 +0100 Subject: [PATCH] More review comments --- .../dendrite/federationsender/consumers/roomserver.go | 4 ++-- .../federationsender/storage/joined_hosts_table.go | 5 +++-- .../dendrite/federationsender/storage/storage.go | 3 ++- .../dendrite/federationsender/types/types.go | 10 +++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go b/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go index 7aea6fdf4..fd3e5c007 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go +++ b/src/github.com/matrix-org/dendrite/federationsender/consumers/roomserver.go @@ -185,7 +185,7 @@ func (s *OutputRoomEvent) joinedHostsAtEvent( joined := map[gomatrixserverlib.ServerName]bool{} for _, joinedHost := range oldJoinedHosts { - if removed[joinedHost.EventID] { + if removed[joinedHost.MemberEventID] { // This m.room.member event is part of the current state of the // room, but not part of the state at the event we are processing // Therefore we can't use it to tell whether the server was in @@ -233,7 +233,7 @@ func joinedHostsFromEvents(evs []gomatrixserverlib.Event) ([]types.JoinedHost, e return nil, err } joinedHosts = append(joinedHosts, types.JoinedHost{ - EventID: ev.EventID(), ServerName: serverName, + MemberEventID: ev.EventID(), ServerName: serverName, }) } return joinedHosts, nil diff --git a/src/github.com/matrix-org/dendrite/federationsender/storage/joined_hosts_table.go b/src/github.com/matrix-org/dendrite/federationsender/storage/joined_hosts_table.go index 366af1292..dcbc62a88 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/storage/joined_hosts_table.go +++ b/src/github.com/matrix-org/dendrite/federationsender/storage/joined_hosts_table.go @@ -16,6 +16,7 @@ package storage import ( "database/sql" + "github.com/lib/pq" "github.com/matrix-org/dendrite/federationsender/types" "github.com/matrix-org/gomatrixserverlib" @@ -101,8 +102,8 @@ func (s *joinedHostsStatements) selectJoinedHosts(txn *sql.Tx, roomID string, return nil, err } result = append(result, types.JoinedHost{ - EventID: eventID, - ServerName: gomatrixserverlib.ServerName(serverName), + MemberEventID: eventID, + ServerName: gomatrixserverlib.ServerName(serverName), }) } return result, nil diff --git a/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go b/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go index b27fbd78f..ca820b195 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go +++ b/src/github.com/matrix-org/dendrite/federationsender/storage/storage.go @@ -16,6 +16,7 @@ package storage import ( "database/sql" + "github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/federationsender/types" ) @@ -91,7 +92,7 @@ func (d *Database) UpdateRoom( return err } for _, add := range addHosts { - err = d.insertJoinedHosts(txn, roomID, add.EventID, add.ServerName) + err = d.insertJoinedHosts(txn, roomID, add.MemberEventID, add.ServerName) if err != nil { return err } diff --git a/src/github.com/matrix-org/dendrite/federationsender/types/types.go b/src/github.com/matrix-org/dendrite/federationsender/types/types.go index 0fbd4aa06..47b58ddf9 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/types/types.go +++ b/src/github.com/matrix-org/dendrite/federationsender/types/types.go @@ -22,14 +22,14 @@ import ( // A JoinedHost is a server that is joined to a matrix room. type JoinedHost struct { - // The EventID of a m.room.member join event. - EventID string + // The MemberEventID of a m.room.member join event. + MemberEventID string // The domain part of the state key of the m.room.member join event ServerName gomatrixserverlib.ServerName } // A EventIDMismatchError indicates that we have got out of sync with the -// rooms erver. +// rooms server. type EventIDMismatchError struct { // The event ID we have stored in our local database. DatabaseID string @@ -37,9 +37,9 @@ type EventIDMismatchError struct { RoomServerID string } -func (l EventIDMismatchError) Error() string { +func (e EventIDMismatchError) Error() string { return fmt.Sprintf( "mismatched last sent event ID: had %q in database got %q from room server", - l.DatabaseID, l.RoomServerID, + e.DatabaseID, e.RoomServerID, ) }