Remove EncodeUTF8 infavour of using attribute casting only. The implementation of EncodeUTF8 was not correct, essentially removing any previous casting causing issues when saving a record.

This commit is contained in:
2024-06-01 10:46:02 +10:00
parent b5047c52f0
commit 73cf421739
10 changed files with 66 additions and 164 deletions

View File

@@ -14,21 +14,17 @@ use Illuminate\Support\Facades\Notification;
use App\Classes\FTN\Message;
use App\Models\{Echomail,Netmail,User};
use App\Notifications\Netmails\{EchoareaNotExist,EchoareaNotSubscribed,EchoareaNoWrite,NetmailForward,NetmailHubNoUser};
use App\Traits\{EncodeUTF8,ParseAddresses};
use App\Traits\ParseAddresses;
class MessageProcess implements ShouldQueue
{
private const LOGKEY = 'JMP';
use Dispatchable,InteractsWithQueue,Queueable,SerializesModels,ParseAddresses,EncodeUTF8;
use Dispatchable,InteractsWithQueue,Queueable,SerializesModels,ParseAddresses;
private Echomail|Netmail|string $mo;
private bool $skipbot;
private const cast_utf8 = [
'mo',
];
/**
* Process a message from a packet
*
@@ -54,16 +50,6 @@ class MessageProcess implements ShouldQueue
}
}
public function __serialize()
{
return $this->encode();
}
public function __unserialize(array $values)
{
$this->decode($values);
}
/**
* At this point, we know that the packet is from a system we know about, and the packet is to us:
* + From a system that is configured with us, and the password has been validated
@@ -144,8 +130,8 @@ class MessageProcess implements ShouldQueue
// Check if the netmail is to a user, with netmail forwarding enabled
$uo = User::active()
->where(function($query) {
return $query->whereRaw(sprintf("LOWER(name)='%s'",strtolower($this->mo->to)))
->orWhereRaw(sprintf("LOWER(alias)='%s'",strtolower($this->mo->to)));
return $query->whereRaw(sprintf("LOWER(name)='%s'",strtolower(utf8_encode($this->mo->to))))
->orWhereRaw(sprintf("LOWER(alias)='%s'",strtolower(utf8_encode($this->mo->to))));
})
->whereNotNull('system_id')
->single();