fix query
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import axios, { Method } from 'axios'
|
||||
import { findWebhooksByEventTypes } from '../services/webhook'
|
||||
import { findWebhooksByEventType } from '../services/webhook'
|
||||
import { logger } from '../utils/logger'
|
||||
|
||||
export interface CallWebhookJobData {
|
||||
@ -15,7 +15,7 @@ const TIMEOUT = 5000 // 5s
|
||||
export const callWebhook = async (jobData: CallWebhookJobData) => {
|
||||
const { data, type, action, userId } = jobData
|
||||
const eventType = `${type}_${action}`.toUpperCase()
|
||||
const webhooks = await findWebhooksByEventTypes(userId, [eventType])
|
||||
const webhooks = await findWebhooksByEventType(userId, eventType)
|
||||
|
||||
if (webhooks.length <= 0) {
|
||||
return
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ArrayContainedBy, ArrayContains, ILike } from 'typeorm'
|
||||
import { ArrayContains, ILike } from 'typeorm'
|
||||
import { Rule, RuleAction, RuleEventType } from '../entity/rule'
|
||||
import { authTrx, getRepository } from '../repository'
|
||||
|
||||
@ -61,6 +61,6 @@ export const findEnabledRules = async (
|
||||
return getRepository(Rule).findBy({
|
||||
user: { id: userId },
|
||||
enabled: true,
|
||||
eventTypes: ArrayContainedBy([eventType]),
|
||||
eventTypes: ArrayContains([eventType]),
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { ArrayContainedBy, DeepPartial, EntityManager } from 'typeorm'
|
||||
import { ArrayContains, DeepPartial, EntityManager } from 'typeorm'
|
||||
import { Webhook } from '../entity/webhook'
|
||||
import { authTrx } from '../repository'
|
||||
|
||||
@ -34,16 +34,16 @@ export const findWebhooks = async (userId: string) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const findWebhooksByEventTypes = async (
|
||||
export const findWebhooksByEventType = async (
|
||||
userId: string,
|
||||
eventTypes: string[]
|
||||
eventType: string
|
||||
) => {
|
||||
return authTrx(
|
||||
(tx) =>
|
||||
tx.getRepository(Webhook).findBy({
|
||||
user: { id: userId },
|
||||
enabled: true,
|
||||
eventTypes: ArrayContainedBy(eventTypes),
|
||||
eventTypes: ArrayContains([eventType]),
|
||||
}),
|
||||
undefined,
|
||||
userId
|
||||
|
||||
Reference in New Issue
Block a user