• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Freegle / Iznik / 11307

08 May 2026 12:02PM UTC coverage: 72.829% (+0.07%) from 72.761%
11307

Pull #401

circleci

edwh
feat(batch): migrate chat_process.php to chats:process-incoming

Process pending chat messages (processingrequired=1) in Laravel batch.
Mirrors V1 cron/chat_process.php + ChatMessage::process().

IncomingMailService creates messages with processingrequired=1 (with comment
'Background chat_process.php cron handles visibility, roster, push
notifications'). Without this migration those incoming mail replies were
invisible to ChatNotificationService (which filters on processingrequired=0
AND processingsuccessful=1).

Key operations per message:
- Spam/ban checks for User2User chats (spam_users, users_banned, chatmodstatus)
- Review cascade: hold new message if previous message in chat is under review
- Mark processingrequired=0, processingsuccessful=1 (or 0 on failure)
- Update sender's chat_roster (lastmsgseen/lastmsgemailed)
- Reopen CLOSED roster entries (not BLOCKED) after new activity

Scheduler entry commented out in routes/console.php pending sign-off.
10 tests covering all transitions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pull Request #401: feat(batch): migrate chat_process.php to chats:process-incoming

13699 of 20568 branches covered (66.6%)

Branch coverage included in aggregate %.

230 of 279 new or added lines in 4 files covered. (82.44%)

19 existing lines in 4 files now uncovered.

101296 of 137329 relevant lines covered (73.76%)

22.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iznik-batch/app/Console/Commands/Chat/ProcessIncomingChatCommand.php
1
<?php
2

3
namespace App\Console\Commands\Chat;
4

5
use App\Console\Concerns\PreventsOverlapping;
6
use App\Services\ChatProcessService;
7
use App\Traits\GracefulShutdown;
8
use Illuminate\Console\Command;
9
use Illuminate\Support\Facades\Log;
10

11
class ProcessIncomingChatCommand extends Command
12
{
13
    use PreventsOverlapping;
14
    use GracefulShutdown;
15

16
    protected $signature = 'chats:process-incoming
17
                            {--dry-run : Show what would be processed without making changes}';
18

19
    protected $description = 'Process pending chat messages (processingrequired=1) — spam checks, roster update, reopen closed chats';
20

NEW
21
    public function handle(ChatProcessService $service): int
×
22
    {
NEW
23
        if (!$this->acquireLock()) {
×
NEW
24
            $this->info('Already running, exiting.');
×
NEW
25
            return Command::SUCCESS;
×
26
        }
27

28
        try {
NEW
29
            if ($this->option('dry-run')) {
×
NEW
30
                $count = \Illuminate\Support\Facades\DB::table('chat_messages')
×
NEW
31
                    ->where('processingrequired', 1)
×
NEW
32
                    ->count();
×
NEW
33
                $this->info("Dry run — {$count} message(s) would be processed.");
×
NEW
34
                return Command::SUCCESS;
×
35
            }
36

NEW
37
            Log::info('Starting chat message processing');
×
38

NEW
39
            $count = $service->processIncoming();
×
40

NEW
41
            $this->info("{$count} message(s) processed");
×
NEW
42
            Log::info('Chat message processing complete', ['count' => $count]);
×
43

NEW
44
            return Command::SUCCESS;
×
45
        } finally {
NEW
46
            $this->releaseLock();
×
47
        }
48
    }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc