后端迁移Webhook服务
This commit is contained in:
+13
-2
@@ -16,6 +16,13 @@ import { logWebhook } from '../../utils/logger.js'
|
||||
import { parseAmountToFen } from '../../utils/money.js'
|
||||
import { nowIso } from '../../utils/time.js'
|
||||
|
||||
type AgisoTradeWebhookDeps = {
|
||||
updateWebhookEvent?: typeof updateWebhookEvent
|
||||
hasConfiguredOrderItems?: typeof hasConfiguredOrderItems
|
||||
upsertOrderFromWebhook?: typeof upsertOrderFromWebhook
|
||||
enrichAgisoXianyuTradeOrder?: typeof enrichAgisoXianyuTradeOrder
|
||||
}
|
||||
|
||||
export async function processAgisoTradeWebhook(requestLike) {
|
||||
const parsed = parseAgisoTradeRequest(requestLike)
|
||||
const webhookEvent = await createWebhookEvent(buildWebhookEventInput(requestLike, parsed))
|
||||
@@ -87,7 +94,7 @@ export async function executeAgisoTradeWebhookWithDeps(
|
||||
parsed,
|
||||
webhookEventId,
|
||||
{ requestId = '' } = {},
|
||||
deps = {},
|
||||
deps: AgisoTradeWebhookDeps = {},
|
||||
) {
|
||||
const updateEvent = deps.updateWebhookEvent || updateWebhookEvent
|
||||
const hasConfiguredItems = deps.hasConfiguredOrderItems || hasConfiguredOrderItems
|
||||
@@ -280,7 +287,11 @@ export async function executeAgisoTradeWebhookWithDeps(
|
||||
}
|
||||
}
|
||||
|
||||
async function enrichTradeBeforeUpsert(parsed, { requestId = '', webhookEventId = null } = {}, deps = {}) {
|
||||
async function enrichTradeBeforeUpsert(
|
||||
parsed,
|
||||
{ requestId = '', webhookEventId = null } = {},
|
||||
deps: AgisoTradeWebhookDeps = {},
|
||||
) {
|
||||
const enrichOrder = deps.enrichAgisoXianyuTradeOrder || enrichAgisoXianyuTradeOrder
|
||||
|
||||
if (parsed.provider !== 'agiso' || parsed.platform !== 'xianyu') {
|
||||
Reference in New Issue
Block a user