mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
Merge pull request #246 from iRubbish/feat/webhook-account-notification
feat: 添加账号禁用异常状态 Webhook 通知功能 (已格式化)
This commit is contained in:
@@ -403,6 +403,9 @@ class ClaudeConsoleAccountService {
|
||||
try {
|
||||
const client = redis.getClientSafe()
|
||||
|
||||
// 获取账户信息用于webhook通知
|
||||
const accountData = await client.hgetall(`${this.ACCOUNT_KEY_PREFIX}${accountId}`)
|
||||
|
||||
const updates = {
|
||||
status: 'blocked',
|
||||
errorMessage: reason,
|
||||
@@ -412,6 +415,24 @@ class ClaudeConsoleAccountService {
|
||||
await client.hset(`${this.ACCOUNT_KEY_PREFIX}${accountId}`, updates)
|
||||
|
||||
logger.warn(`🚫 Claude Console account blocked: ${accountId} - ${reason}`)
|
||||
|
||||
// 发送Webhook通知
|
||||
if (accountData && Object.keys(accountData).length > 0) {
|
||||
try {
|
||||
const webhookNotifier = require('../utils/webhookNotifier')
|
||||
await webhookNotifier.sendAccountAnomalyNotification({
|
||||
accountId,
|
||||
accountName: accountData.name || 'Unknown Account',
|
||||
platform: 'claude-console',
|
||||
status: 'blocked',
|
||||
errorCode: 'CLAUDE_CONSOLE_BLOCKED',
|
||||
reason
|
||||
})
|
||||
} catch (webhookError) {
|
||||
logger.error('Failed to send webhook notification:', webhookError)
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
logger.error(`❌ Failed to block Claude Console account: ${accountId}`, error)
|
||||
|
||||
Reference in New Issue
Block a user