Move the send DB updates out of the protocol and into Send::class

This commit is contained in:
2023-07-19 12:32:41 +10:00
parent 7584e3e44e
commit f4fc6c24a4
6 changed files with 67 additions and 58 deletions

View File

@@ -2,9 +2,12 @@
namespace App\Classes\File;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use App\Classes\Node;
use App\Models\File as FileModel;
final class File extends Send
@@ -49,11 +52,22 @@ final class File extends Send
}
}
public function close(bool $successful): void
public function close(bool $successful,Node $node): void
{
if ($successful)
if ($successful) {
$this->complete = TRUE;
if (($this->type === Send::T_FILE)
&& ($x=$this->dbids)->count()
&& $node->aka_remote_authed->count())
DB::table('file_seenby')
->whereIn('file_id',$x)
->whereIn('address_id',$node->aka_remote_authed->pluck('id'))
->update([
'sent_at'=>Carbon::now(),
]);
}
fclose($this->fd);
}