统一前后端代码格式化配置
This commit is contained in:
@@ -37,59 +37,79 @@ export async function sendInternalNotification(input: NotificationInput = {}) {
|
||||
}
|
||||
|
||||
const results = [
|
||||
...(await Promise.all(barkRecipients.map(async (recipient: JsonObject) => {
|
||||
try {
|
||||
const result = await sendBarkNotification({
|
||||
recipient,
|
||||
title,
|
||||
body,
|
||||
group: `订单系统/${category}`,
|
||||
...(bark.serverUrl !== undefined ? { serverUrl: bark.serverUrl } : {}),
|
||||
...(input.url !== undefined ? { url: input.url } : {}),
|
||||
})
|
||||
return mapNotificationResult('bark', recipient, recipient.deviceKey, true, '', result.status, result.response)
|
||||
} catch (error) {
|
||||
logWarn('[notification/bark]', 'Bark 内部通知发送失败', {
|
||||
recipientId: recipient.id,
|
||||
recipientName: recipient.name,
|
||||
error,
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'bark',
|
||||
recipient,
|
||||
recipient.deviceKey,
|
||||
false,
|
||||
error instanceof Error ? error.message : 'Bark 内部通知发送失败',
|
||||
isPlainObject(error) ? Number(error.statusCode || 0) || 0 : 0,
|
||||
isPlainObject(error) ? error.context || null : null,
|
||||
)
|
||||
}
|
||||
}))),
|
||||
...(await Promise.all(wpushRecipients.map(async (recipient: JsonObject) => {
|
||||
try {
|
||||
const result = await sendWpushNotification({
|
||||
recipient,
|
||||
title,
|
||||
body,
|
||||
})
|
||||
return mapNotificationResult('wpush', recipient, recipient.apiKey, true, '', result.status, result.response)
|
||||
} catch (error) {
|
||||
logWarn('[notification/wpush]', 'WPush 内部通知发送失败', {
|
||||
recipientId: recipient.id,
|
||||
recipientName: recipient.name,
|
||||
error,
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'wpush',
|
||||
recipient,
|
||||
recipient.apiKey,
|
||||
false,
|
||||
error instanceof Error ? error.message : 'WPush 内部通知发送失败',
|
||||
isPlainObject(error) ? Number(error.statusCode || 0) || 0 : 0,
|
||||
isPlainObject(error) ? error.context || null : null,
|
||||
)
|
||||
}
|
||||
}))),
|
||||
...(await Promise.all(
|
||||
barkRecipients.map(async (recipient: JsonObject) => {
|
||||
try {
|
||||
const result = await sendBarkNotification({
|
||||
recipient,
|
||||
title,
|
||||
body,
|
||||
group: `订单系统/${category}`,
|
||||
...(bark.serverUrl !== undefined ? { serverUrl: bark.serverUrl } : {}),
|
||||
...(input.url !== undefined ? { url: input.url } : {}),
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'bark',
|
||||
recipient,
|
||||
recipient.deviceKey,
|
||||
true,
|
||||
'',
|
||||
result.status,
|
||||
result.response,
|
||||
)
|
||||
} catch (error) {
|
||||
logWarn('[notification/bark]', 'Bark 内部通知发送失败', {
|
||||
recipientId: recipient.id,
|
||||
recipientName: recipient.name,
|
||||
error,
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'bark',
|
||||
recipient,
|
||||
recipient.deviceKey,
|
||||
false,
|
||||
error instanceof Error ? error.message : 'Bark 内部通知发送失败',
|
||||
isPlainObject(error) ? Number(error.statusCode || 0) || 0 : 0,
|
||||
isPlainObject(error) ? error.context || null : null,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)),
|
||||
...(await Promise.all(
|
||||
wpushRecipients.map(async (recipient: JsonObject) => {
|
||||
try {
|
||||
const result = await sendWpushNotification({
|
||||
recipient,
|
||||
title,
|
||||
body,
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'wpush',
|
||||
recipient,
|
||||
recipient.apiKey,
|
||||
true,
|
||||
'',
|
||||
result.status,
|
||||
result.response,
|
||||
)
|
||||
} catch (error) {
|
||||
logWarn('[notification/wpush]', 'WPush 内部通知发送失败', {
|
||||
recipientId: recipient.id,
|
||||
recipientName: recipient.name,
|
||||
error,
|
||||
})
|
||||
return mapNotificationResult(
|
||||
'wpush',
|
||||
recipient,
|
||||
recipient.apiKey,
|
||||
false,
|
||||
error instanceof Error ? error.message : 'WPush 内部通知发送失败',
|
||||
isPlainObject(error) ? Number(error.statusCode || 0) || 0 : 0,
|
||||
isPlainObject(error) ? error.context || null : null,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)),
|
||||
]
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user