mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 01:05:30 +08:00
feat: 统一发送能力 接入退群通知与定时日报
This commit is contained in:
1 parent
e1f4ec79dd
commit
27f4108cf9
9 files changed
+150
-54
No files matched your search
@@ -644,7 +644,7 @@ export class ScheduledReportService {
|
||||
fallbackStage: ScheduledReportExecutionStage,
|
||||
status: 'failed' | 'waiting_to_send' | 'partial_success' = 'failed',
|
||||
patch: Partial<ScheduledReportExecution> = {},
|
||||
notificationType: ScheduledReportNotificationType = 'failure',
|
||||
notificationType: ScheduledReportNotificationType | null = 'failure',
|
||||
code?: string,
|
||||
errorStatus?: number,
|
||||
errorType?: string
|
||||
@@ -691,13 +691,15 @@ export class ScheduledReportService {
|
||||
suggestedAction: normalized.suggestedAction,
|
||||
retryable: normalized.retryable
|
||||
},
|
||||
{
|
||||
type: notificationType,
|
||||
severity: normalized.severity,
|
||||
title: normalized.userTitle,
|
||||
message: normalized.userMessage,
|
||||
suggestedAction: normalized.suggestedAction
|
||||
}
|
||||
notificationType
|
||||
? {
|
||||
type: notificationType,
|
||||
severity: normalized.severity,
|
||||
title: normalized.userTitle,
|
||||
message: normalized.userMessage,
|
||||
suggestedAction: normalized.suggestedAction
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
return completed
|
||||
}
|
||||
@@ -840,7 +842,7 @@ export class ScheduledReportService {
|
||||
sendStatus: unavailable ? 'unavailable' : 'failed',
|
||||
sendError: actionError
|
||||
},
|
||||
'partial_success',
|
||||
unavailable ? null : 'partial_success',
|
||||
unavailable ? 'WECHAT_SEND_UNAVAILABLE' : 'WECHAT_SEND_FAILED'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ export interface WechatActionGatewayDependencies {
|
||||
| WechatActionMemberEventReference
|
||||
| Promise<WechatActionMemberEventReference | undefined>
|
||||
| undefined
|
||||
checkEntitlement?: (request: WechatActionRequest) => boolean | Promise<boolean>
|
||||
getUserDataPath?: () => string
|
||||
now?: () => Date
|
||||
}
|
||||
@@ -140,33 +139,6 @@ export class WechatActionGateway {
|
||||
)
|
||||
}
|
||||
|
||||
let entitled = true
|
||||
try {
|
||||
entitled = this.deps.checkEntitlement
|
||||
? await this.deps.checkEntitlement(request)
|
||||
: await checkEntitlement(request)
|
||||
} catch (error) {
|
||||
entitled = false
|
||||
return this.finishBlocked(
|
||||
actionId,
|
||||
request,
|
||||
idempotencyKey,
|
||||
startedAt,
|
||||
'POLICY_BLOCKED',
|
||||
error instanceof Error ? error.message : String(error)
|
||||
)
|
||||
}
|
||||
if (!entitled) {
|
||||
return this.finishBlocked(
|
||||
actionId,
|
||||
request,
|
||||
idempotencyKey,
|
||||
startedAt,
|
||||
'POLICY_BLOCKED',
|
||||
'该发送动作未获得当前账号的使用权限'
|
||||
)
|
||||
}
|
||||
|
||||
const capabilityType = request.content.type
|
||||
let capability: PersonalWechatSendCapability | undefined
|
||||
try {
|
||||
@@ -483,12 +455,6 @@ export function shouldUseAiPolicy(request: WechatActionRequest): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
/** 当前默认允许发送,后续可在这里补充权限限制。 */
|
||||
export function checkEntitlement(request: WechatActionRequest): boolean {
|
||||
void request
|
||||
return true
|
||||
}
|
||||
|
||||
export function normalizeActionRequest(value: unknown): WechatActionRequest | null {
|
||||
if (!value || typeof value !== 'object') return null
|
||||
const input = value as Partial<WechatActionRequest>
|
||||
|
||||
@@ -1937,7 +1937,13 @@ function App(): React.ReactElement {
|
||||
case 'report':
|
||||
return renderReportWorkspace()
|
||||
case 'exit-monitor':
|
||||
return <GroupExitMonitorWorkspace dbReady={isDatabaseConnected} contacts={contacts} />
|
||||
return (
|
||||
<GroupExitMonitorWorkspace
|
||||
dbReady={isDatabaseConnected}
|
||||
contacts={contacts}
|
||||
onOpenSendSettings={openWechatSendSettings}
|
||||
/>
|
||||
)
|
||||
case 'agent-hub':
|
||||
return <AgentHubWorkspace />
|
||||
case 'api':
|
||||
|
||||
@@ -31,6 +31,7 @@ type GroupSelectionFilter = 'all' | 'selected' | 'unselected'
|
||||
interface GroupExitMonitorWorkspaceProps {
|
||||
dbReady: boolean
|
||||
contacts?: Contact[]
|
||||
onOpenSendSettings?: () => void
|
||||
}
|
||||
|
||||
const EMPTY_STATE: GroupExitMonitorState = {
|
||||
@@ -81,9 +82,11 @@ const sendCapabilityTone = (capability: PersonalWechatSendCapability | null): st
|
||||
capability?.ready && capability.capabilities.text ? 'ready' : 'unready'
|
||||
|
||||
function EventNotificationStatus({
|
||||
event
|
||||
event,
|
||||
onOpenSendSettings
|
||||
}: {
|
||||
event: GroupExitMonitorState['events'][number]
|
||||
onOpenSendSettings?: () => void
|
||||
}): React.ReactElement {
|
||||
const status = event.notificationStatus || event.notification?.status || 'not_requested'
|
||||
const details =
|
||||
@@ -108,6 +111,13 @@ function EventNotificationStatus({
|
||||
<div className={`exit-monitor-event-notification ${details.tone}`}>
|
||||
<span>{details.label}</span>
|
||||
{details.description ? <small>{details.description}</small> : null}
|
||||
{(event.notification?.errorCode === 'SEND_CAPABILITY_UNAVAILABLE' ||
|
||||
event.notification?.errorCode === 'SEND_NOT_READY') &&
|
||||
onOpenSendSettings ? (
|
||||
<Button variant="link" size="sm" onClick={onOpenSendSettings}>
|
||||
去设置
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -428,7 +438,8 @@ function ManageGroups({
|
||||
|
||||
export function GroupExitMonitorWorkspace({
|
||||
dbReady,
|
||||
contacts = []
|
||||
contacts = [],
|
||||
onOpenSendSettings
|
||||
}: GroupExitMonitorWorkspaceProps): React.ReactElement {
|
||||
const [state, setState] = React.useState<GroupExitMonitorState>(EMPTY_STATE)
|
||||
const [checking, setChecking] = React.useState(false)
|
||||
@@ -815,7 +826,10 @@ export function GroupExitMonitorWorkspace({
|
||||
群人数 {event.previousCount} 人 → {event.currentCount} 人
|
||||
</p>
|
||||
) : null}
|
||||
<EventNotificationStatus event={event} />
|
||||
<EventNotificationStatus
|
||||
event={event}
|
||||
onOpenSendSettings={onOpenSendSettings}
|
||||
/>
|
||||
<dl className="exit-monitor-event-details">
|
||||
<div>
|
||||
<dt>微信名</dt>
|
||||
|
||||
Reference in new issue
Block a user