0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-12-15 05:13:43 +01:00

Scan AppServiceID from accounts table, fix typo (#474)

This commit is contained in:
Anant Prakash 2018-05-31 15:16:50 +05:30 committed by Andrew Morgan
parent 04551becb4
commit 7ac1efc4b3

View file

@ -44,7 +44,7 @@ const insertAccountSQL = "" +
"INSERT INTO account_accounts(localpart, created_ts, password_hash, appservice_id) VALUES ($1, $2, $3, $4)" "INSERT INTO account_accounts(localpart, created_ts, password_hash, appservice_id) VALUES ($1, $2, $3, $4)"
const selectAccountByLocalpartSQL = "" + const selectAccountByLocalpartSQL = "" +
"SELECT localpart FROM account_accounts WHERE localpart = $1" "SELECT localpart, appservice_id FROM account_accounts WHERE localpart = $1"
const selectPasswordHashSQL = "" + const selectPasswordHashSQL = "" +
"SELECT password_hash FROM account_accounts WHERE localpart = $1" "SELECT password_hash FROM account_accounts WHERE localpart = $1"
@ -112,15 +112,14 @@ func (s *accountsStatements) selectPasswordHash(
func (s *accountsStatements) selectAccountByLocalpart( func (s *accountsStatements) selectAccountByLocalpart(
ctx context.Context, localpart string, ctx context.Context, localpart string,
) (*authtypes.Account, error) { ) (acc *authtypes.Account, err error) {
var acc authtypes.Account
stmt := s.selectAccountByLocalpartStmt stmt := s.selectAccountByLocalpartStmt
err := stmt.QueryRowContext(ctx, localpart).Scan(&acc.Localpart) err = stmt.QueryRowContext(ctx, localpart).Scan(&acc.Localpart, &acc.AppServiceID)
if err != nil { if err == nil {
acc.UserID = makeUserID(localpart, s.serverName) acc.UserID = makeUserID(localpart, s.serverName)
acc.ServerName = s.serverName acc.ServerName = s.serverName
} }
return &acc, err return
} }
func makeUserID(localpart string, server gomatrixserverlib.ServerName) string { func makeUserID(localpart string, server gomatrixserverlib.ServerName) string {