fix(backend): replace $contains with post-filter for webhook events array query
$contains generates CONTAINS() SQL in Cosmos (string match), not ARRAY_CONTAINS() needed for string[] fields. Use findMany + in-memory post-filter for correct behavior across both providers.
This commit is contained in:
parent
8731cf38fd
commit
4cb5d3e627
@ -96,10 +96,12 @@ export async function findSubscriptionsForEvent(
|
|||||||
productId: string,
|
productId: string,
|
||||||
eventType: WebhookEventType
|
eventType: WebhookEventType
|
||||||
): Promise<WebhookSubscriptionDoc[]> {
|
): Promise<WebhookSubscriptionDoc[]> {
|
||||||
// events is a string[] — $contains works for primitive arrays in memory provider
|
// $contains generates CONTAINS() SQL (string match) in Cosmos, not ARRAY_CONTAINS().
|
||||||
return subsCollection().findMany({
|
// Use findMany + post-filter for correct behavior across both providers.
|
||||||
filter: { userId, productId, active: true, events: { $contains: eventType } },
|
const subs = await subsCollection().findMany({
|
||||||
|
filter: { userId, productId, active: true },
|
||||||
});
|
});
|
||||||
|
return subs.filter(s => s.events.includes(eventType));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Increment Failure Count ───────────────────────────────────
|
// ── Increment Failure Count ───────────────────────────────────
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user