More review comments

This commit is contained in:
Mark Haines 2017-06-28 14:02:13 +01:00
parent f26dad5dce
commit da858d6b65
4 changed files with 12 additions and 10 deletions

View file

@ -185,7 +185,7 @@ func (s *OutputRoomEvent) joinedHostsAtEvent(
joined := map[gomatrixserverlib.ServerName]bool{} joined := map[gomatrixserverlib.ServerName]bool{}
for _, joinedHost := range oldJoinedHosts { 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 // 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 // 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 // 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 return nil, err
} }
joinedHosts = append(joinedHosts, types.JoinedHost{ joinedHosts = append(joinedHosts, types.JoinedHost{
EventID: ev.EventID(), ServerName: serverName, MemberEventID: ev.EventID(), ServerName: serverName,
}) })
} }
return joinedHosts, nil return joinedHosts, nil

View file

@ -16,6 +16,7 @@ package storage
import ( import (
"database/sql" "database/sql"
"github.com/lib/pq" "github.com/lib/pq"
"github.com/matrix-org/dendrite/federationsender/types" "github.com/matrix-org/dendrite/federationsender/types"
"github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/gomatrixserverlib"
@ -101,8 +102,8 @@ func (s *joinedHostsStatements) selectJoinedHosts(txn *sql.Tx, roomID string,
return nil, err return nil, err
} }
result = append(result, types.JoinedHost{ result = append(result, types.JoinedHost{
EventID: eventID, MemberEventID: eventID,
ServerName: gomatrixserverlib.ServerName(serverName), ServerName: gomatrixserverlib.ServerName(serverName),
}) })
} }
return result, nil return result, nil

View file

@ -16,6 +16,7 @@ package storage
import ( import (
"database/sql" "database/sql"
"github.com/matrix-org/dendrite/common" "github.com/matrix-org/dendrite/common"
"github.com/matrix-org/dendrite/federationsender/types" "github.com/matrix-org/dendrite/federationsender/types"
) )
@ -91,7 +92,7 @@ func (d *Database) UpdateRoom(
return err return err
} }
for _, add := range addHosts { 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 { if err != nil {
return err return err
} }

View file

@ -22,14 +22,14 @@ import (
// A JoinedHost is a server that is joined to a matrix room. // A JoinedHost is a server that is joined to a matrix room.
type JoinedHost struct { type JoinedHost struct {
// The EventID of a m.room.member join event. // The MemberEventID of a m.room.member join event.
EventID string MemberEventID string
// The domain part of the state key of the m.room.member join event // The domain part of the state key of the m.room.member join event
ServerName gomatrixserverlib.ServerName ServerName gomatrixserverlib.ServerName
} }
// A EventIDMismatchError indicates that we have got out of sync with the // A EventIDMismatchError indicates that we have got out of sync with the
// rooms erver. // rooms server.
type EventIDMismatchError struct { type EventIDMismatchError struct {
// The event ID we have stored in our local database. // The event ID we have stored in our local database.
DatabaseID string DatabaseID string
@ -37,9 +37,9 @@ type EventIDMismatchError struct {
RoomServerID string RoomServerID string
} }
func (l EventIDMismatchError) Error() string { func (e EventIDMismatchError) Error() string {
return fmt.Sprintf( return fmt.Sprintf(
"mismatched last sent event ID: had %q in database got %q from room server", "mismatched last sent event ID: had %q in database got %q from room server",
l.DatabaseID, l.RoomServerID, e.DatabaseID, e.RoomServerID,
) )
} }