Fix for single encoding error, when only the first message was decoded, some logging for Address objects
This commit is contained in:
parent
f216f42917
commit
12a40a79fb
@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Http\Controllers\DomainController;
|
||||
@ -24,6 +25,8 @@ use App\Traits\ScopeActive;
|
||||
*/
|
||||
class Address extends Model
|
||||
{
|
||||
private const LOGKEY = 'MA-';
|
||||
|
||||
use ScopeActive,SoftDeletes;
|
||||
|
||||
protected $with = ['zone'];
|
||||
@ -383,6 +386,7 @@ class Address extends Model
|
||||
* Get echomail for this node
|
||||
*
|
||||
* @param bool $update
|
||||
* @param Collection|null $echomail
|
||||
* @return Packet|null
|
||||
*/
|
||||
public function getEchomail(bool $update=TRUE,Collection $echomail=NULL): ?Packet
|
||||
@ -394,6 +398,8 @@ class Address extends Model
|
||||
if (($x=$this->echomailWaiting())
|
||||
->count())
|
||||
{
|
||||
Log::debug(sprintf('%s:= Got [%d] echomails for [%s] for sending',self::LOGKEY,$x->count(),$this->ftn));
|
||||
|
||||
$pkt = $this->getPacket($x);
|
||||
|
||||
if ($pkt && $pkt->count() && $update)
|
||||
@ -422,6 +428,8 @@ class Address extends Model
|
||||
if (($x=$this->netmailWaiting())
|
||||
->count())
|
||||
{
|
||||
Log::debug(sprintf('%s:= Got [%d] netmails for [%s] for sending',self::LOGKEY,$x->count(),$this->ftn));
|
||||
|
||||
$pkt = $this->getPacket($x);
|
||||
|
||||
if ($pkt && $pkt->count() && $update)
|
||||
@ -436,7 +444,7 @@ class Address extends Model
|
||||
/**
|
||||
* Return a packet of mail
|
||||
*
|
||||
* @param Collection $c
|
||||
* @param Collection $c of message models (Echomail/Netmail)
|
||||
* @return Packet|null
|
||||
*/
|
||||
private function getPacket(Collection $c): ?Packet
|
||||
@ -449,6 +457,7 @@ class Address extends Model
|
||||
|
||||
$o = new Packet($ao,$this);
|
||||
|
||||
// $oo = Netmail/Echomail Model
|
||||
foreach ($c as $oo)
|
||||
$o->addMail($oo->packet($this));
|
||||
|
||||
|
@ -9,6 +9,8 @@ use Illuminate\Support\Arr;
|
||||
|
||||
trait EncodeUTF8
|
||||
{
|
||||
private array $_encoded = []; // Remember what we've decoded - when calling getAttribute()
|
||||
|
||||
private function decode(array $values): void
|
||||
{
|
||||
$properties = (new \ReflectionClass($this))->getProperties();
|
||||
@ -79,11 +81,9 @@ trait EncodeUTF8
|
||||
|
||||
public function getAttribute($key)
|
||||
{
|
||||
static $encoded = [];
|
||||
|
||||
if (in_array($key,self::cast_utf8) && Arr::get($this->attributes,$key) && (! Arr::get($encoded,$key))) {
|
||||
if (in_array($key,self::cast_utf8) && Arr::get($this->attributes,$key) && (! Arr::get($this->_encoded,$key))) {
|
||||
$this->attributes[$key] = utf8_decode($this->attributes[$key]);
|
||||
$encoded[$key] = TRUE;
|
||||
$this->_encoded[$key] = TRUE;
|
||||
}
|
||||
|
||||
return parent::getAttribute($key);
|
||||
|
Loading…
Reference in New Issue
Block a user