This commit is contained in:
Your Name
2026-09-01 11:26:47 +08:00
parent 5bd5eae62d
commit 398f9f3726
357 changed files with 733 additions and 343 deletions
@@ -72,9 +72,10 @@ final class AutomationMemoryStore extends QywxPromotionAutomationStore
public function due(string $lane, int $now, int $limit): array {
return array_keys(array_filter($this->rows, static function (array $r) use ($lane, $now): bool {
$pending = in_array($r['welcome_status'], ['pending', 'retry', 'running'], true);
return $r['status'] !== 'done' && $r['lock_until'] <= $now && ($lane === 'welcome'
? $pending && $r['welcome_next_retry'] <= $now
: (!$pending || $r['welcome_expires_at'] <= $now) && $r['next_retry'] <= $now);
if ($r['status'] === 'done' || $r['lock_until'] > $now) { return false; }
if ($lane === 'welcome') { return $pending && $r['welcome_next_retry'] <= $now; }
if ($lane === 'inline_metadata') { return $r['next_retry'] <= $now; }
return (!$pending || $r['welcome_expires_at'] <= $now) && $r['next_retry'] <= $now;
}));
}
public function claim(int $id, string $lane, int $now): ?array {
@@ -130,6 +131,17 @@ automationCheck(count(array_filter($api->calls, static fn (array $v): bool => $v
automationCheck(count(array_filter($api->calls, static fn (array $v): bool => $v[0] === 'remark')) === 2, 'do not repeat successful remark/description');
automationCheck(!str_contains(json_encode($store->logs), 'NEVER_LOG_THIS_CODE'), 'audit contains no code');
[$service, $store, $api] = $fixture();
$api->welcomeError = new QywxPromotionContactApiException('other app currently sending', 41096);
automationCheck($service->enqueueVerifiedEvent(array_replace($event, ['CreateTime' => $now]), true), 'callback immediate lane handled');
$actions = json_decode($store->rows[1]['actions_json'], true);
automationCheck(array_column($api->calls, 0) === ['welcome', 'tags'], 'callback immediately attempts welcome then tags');
automationCheck(
$actions['welcome']['status'] === 'retry' && $actions['tags']['status'] === 'success',
'tag send is independent from retryable welcome: ' . json_encode([$actions['welcome'], $actions['tags']])
);
automationCheck($store->syncs === [], 'callback immediate lane leaves slow actions to background job');
foreach (['default', 'none'] as $mode) {
[$service, $store, $api] = $fixture(); $store->config['welcome_mode'] = $mode;
$service->enqueueVerifiedEvent(array_replace($event, ['CreateTime' => $now]));