Determine unsent netmails by their flags, not sent_at for the status

This commit is contained in:
Deon George 2023-11-24 22:48:01 +11:00
parent eab35d4c18
commit e337a29003

View File

@ -10,7 +10,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use App\Classes\File; use App\Classes\File;
use App\Classes\FTN\Packet; use App\Classes\FTN\{Message,Packet};
use App\Http\Requests\SetupRequest; use App\Http\Requests\SetupRequest;
use App\Models\File as FileModel; use App\Models\File as FileModel;
use App\Models\{Address,Echomail,Netmail,Setup,System}; use App\Models\{Address,Echomail,Netmail,Setup,System};
@ -259,7 +259,11 @@ class HomeController extends Controller
$n = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('count(*) as n'),DB::raw('0 as f')]) $n = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('count(*) as n'),DB::raw('0 as f')])
->join('netmails',['netmails.tftn_id'=>'addresses.id']) ->join('netmails',['netmails.tftn_id'=>'addresses.id'])
->whereNull('sent_at') ->where(function($query) {
return $query->whereRaw(sprintf('(flags & %d) > 0',Message::FLAG_INTRANSIT))
->orWhereRaw(sprintf('(flags & %d) > 0',Message::FLAG_LOCAL));
})
->whereRaw(sprintf('(flags & %d) = 0',Message::FLAG_SENT))
->where('datetime','<',$date) ->where('datetime','<',$date)
->groupBy('addresses.id'); ->groupBy('addresses.id');