Catch Exception when interpretting date, Create MSGID if it doesnt exist, Fix when \r\n is used in messages.

This commit is contained in:
Deon George 2021-08-27 23:16:39 +10:00
parent ba7f9c1c99
commit 85d9dd1545
2 changed files with 17 additions and 5 deletions

View File

@ -307,9 +307,15 @@ class Message extends FTNBase
return Address::findFTN($this->tboss);
case 'date':
try {
return Carbon::createFromFormat('d M y H:i:s O',
sprintf('%s %s%04d',chop(Arr::get($this->header,$key)),($this->tzutc < 0) ? '-' : '+',abs($this->tzutc)));
} catch (\Exception $e) {
Log::error(sprintf('%s: ! Date doesnt parse [%s] (%s)',self::LOGKEY,$e->getMessage(),Arr::get($this->header,$key)));
return NULL;
}
case 'flags':
case 'cost':
return Arr::get($this->header,$key);
@ -651,6 +657,7 @@ class Message extends FTNBase
{
// Remove DOS \n\r
$message = preg_replace("/\n\r/","\r",$message);
$message = preg_replace("/\r\n/","\r",$message);
// Split out the <SOH> lines
$result = collect(explode("\x01",$message))->filter();

View File

@ -421,13 +421,18 @@ class Packet extends FTNBase implements \Iterator, \Countable
$msg = Message::parseMessage($message,$domain);
// If the message is invalid, we'll ignore it
if ($msg->errors && $msg->errors->messages()->has('from')) {
if ($msg->errors && (
$msg->errors->messages()->has('from')
|| $msg->errors->messages()->has('user_from')
|| $msg->errors->messages()->has('user_to')
))
{
$this->errors->push($msg);
Log::error(sprintf('%s:! %s Skipping...',self::LOGKEY,join('|',$msg->errors->messages()->get('from'))));
Log::error(sprintf('%s:! Skipping message [%s] due to errors (%s)...',self::LOGKEY,$msg->msgid,join(',',$msg->errors->messages()->keys())));
} else {
if ($this->use_redis) {
Redis::set($msg->msgid,serialize($msg));
Redis::set($msg->msgid ?: sprintf('%s %s',$msg->fftn,Carbon::now()->timestamp),serialize($msg));
$this->messages->push($msg->msgid);
} else {