feat(pdd-cookie): 持久化保存Cookie校验状态时间并在失效时发送内部告警通知
This commit is contained in:
@@ -292,3 +292,39 @@ function markNotificationCooldown(cooldownKey: unknown) {
|
||||
|
||||
notificationCooldownMap.set(key, Date.now())
|
||||
}
|
||||
|
||||
|
||||
export interface PddCookieExpiredPayload {
|
||||
shopId: string
|
||||
shopName?: string | undefined
|
||||
message?: string | undefined
|
||||
cooldownSeconds?: number | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Send alert notification when a PDD store's Cookie expires or fails validation.
|
||||
* 拼多多店铺 Cookie 失效或校验未通过时的内部告警通知。
|
||||
*/
|
||||
export function notifyPddCookieExpired({
|
||||
shopId,
|
||||
shopName,
|
||||
message = '商家后台 Cookie 已失效或登录过期',
|
||||
cooldownSeconds = 600,
|
||||
}: PddCookieExpiredPayload) {
|
||||
const normalizedShopId = String(shopId || '').trim()
|
||||
const normalizedShopName = String(shopName || normalizedShopId).trim()
|
||||
|
||||
return notifyInternalSafely({
|
||||
title: `拼多多 Cookie 已失效:${normalizedShopName}`,
|
||||
body: [
|
||||
`店铺:${normalizedShopName} (${normalizedShopId})`,
|
||||
`原因:${String(message || '').trim() || '商家后台 Cookie 已失效,无法自动同步新订单'}`,
|
||||
'请登录拼多多商家后台(mms.pinduoduo.com)重新复制并更新 Cookie,以免漏单。',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n'),
|
||||
category: 'pdd_cookie_expired',
|
||||
cooldownKey: ['pdd_cookie_expired', normalizedShopId || 'default'].join(':'),
|
||||
cooldownMs: Number(cooldownSeconds || 600) * 1000,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user