Scan AppServiceID from accounts table, fix typo (#474)
parent
04551becb4
commit
7ac1efc4b3
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue