amazon events published as server side event

This commit is contained in:
2026-03-03 22:08:58 -07:00
parent 0a03b2e62e
commit 22e7b003f6
9 changed files with 186 additions and 35 deletions
+38
View File
@@ -227,6 +227,44 @@ func (db *Store) GetAccountByEmail(ctx context.Context, email string) (Account,
}, nil
}
func (db *Store) GetAccountIDByMockPlatformAndShopID(ctx context.Context, platform Platform, shopID string) (int64, error) {
info, ok := getMockShopSchemaInfo(platform)
if !ok {
return 0, fmt.Errorf("unrecognized platform: %w", consts.ErrNotFound)
}
rows, err := db.db.Query(
ctx,
fmt.Sprintf(
`
SELECT
account_id
FROM
%s
WHERE
shop_id = @shop_id
`,
info.shopTable,
),
pgx.NamedArgs{
"shop_id": shopID,
},
)
if err != nil {
return 0, fmt.Errorf("failed to perform query: %w", err)
}
acctID, err := pgx.CollectExactlyOneRow(rows, pgx.RowTo[int64])
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return 0, consts.ErrNotFound
}
return 0, fmt.Errorf("failed to scan rows: %w", err)
}
return acctID, nil
}
func (db *Store) GetUserAndAccountByAccessToken(ctx context.Context, accessToken string) (OAuthUser, *Account, error) {
rows, err := db.db.Query(
ctx,