Move the send DB updates out of the protocol and into Send::class
This commit is contained in:
@@ -4,7 +4,10 @@ namespace App\Classes\File;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Classes\Node;
|
||||
use App\Classes\FTN\{Message,Packet};
|
||||
|
||||
final class Mail extends Send
|
||||
{
|
||||
@@ -48,10 +51,35 @@ final class Mail extends Send
|
||||
}
|
||||
}
|
||||
|
||||
public function close(bool $successful): void
|
||||
public function close(bool $successful,Node $node): void
|
||||
{
|
||||
if ($successful)
|
||||
if ($successful) {
|
||||
$this->complete = TRUE;
|
||||
|
||||
// Update netmail table
|
||||
if (($this->type === Send::T_NETMAIL)
|
||||
&& ($x=$this->dbids)->count())
|
||||
DB::table('netmails')
|
||||
->whereIn('id',$x)
|
||||
->update([
|
||||
'sent_at'=>Carbon::now(),
|
||||
'sent_pkt'=>$this->name,
|
||||
'sent_id'=>$node->address->id,
|
||||
'flags'=>DB::raw('flags | '.Message::FLAG_SENT),
|
||||
]);
|
||||
|
||||
// Update echomails table
|
||||
elseif (($this->type === Send::T_ECHOMAIL)
|
||||
&& ($x=$this->dbids)->count()
|
||||
&& $node->aka_remote_authed->count())
|
||||
DB::table('echomail_seenby')
|
||||
->whereIn('echomail_id',$x)
|
||||
->whereIn('address_id',$node->aka_remote_authed->pluck('id'))
|
||||
->update([
|
||||
'sent_at'=>Carbon::now(),
|
||||
'sent_pkt'=>$this->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function feof(): bool
|
||||
|
Reference in New Issue
Block a user