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

main
Anant Prakash 2018-05-31 15:16:50 +05:30 committed by Andrew Morgan
parent 04551becb4
commit 7ac1efc4b3
1 changed files with 5 additions and 6 deletions

View File

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