diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index e3f3228..a7b0cfd 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -219,6 +219,8 @@ class Message extends FTNBase */ public static function parseMessage(string $msg,Zone $zone=NULL): self { + Log::info(sprintf('%s:Processing message [%d] bytes from zone [%d]',self::LOGKEY,strlen($msg),$zone?->zone_id)); + $o = new self($zone); try { diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index da6f910..4d92840 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -422,10 +422,14 @@ class Packet extends FTNBase implements \Iterator, \Countable */ private function parseMessage(string $message): void { + Log::info(sprintf('%s:Processing message [%d] bytes',self::LOGKEY,strlen($message))); + $msg = Message::parseMessage($message,$this->zone); // If the message is invalid, we'll ignore it if ($msg->errors) { + Log::info(sprintf('%s:- Message has errors',self::LOGKEY)); + // If the from address doenst exist, we'll create a new entry if ($msg->errors->messages()->has('from')) { $e = NULL; diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index bf022b6..457e971 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -42,7 +42,7 @@ final class Echomail extends Model implements Packet // @todo if the message is updated with new SEEN-BY's from another route, we'll delete the pending export for systems (if there is one) static::created(function($model) { if (! $model->echoarea_id) { - Log::alert(sprintf('%s:- Message has no echo area, no exporting',self::LOGKEY,$model->id)); + Log::alert(sprintf('%s:- Message has no echo area, not exporting',self::LOGKEY,$model->id)); return; } diff --git a/app/Policies/SystemPolicy.php b/app/Policies/SystemPolicy.php index 864e51c..e66c1a9 100644 --- a/app/Policies/SystemPolicy.php +++ b/app/Policies/SystemPolicy.php @@ -13,12 +13,25 @@ class SystemPolicy /** * Determine whether the user can update the model. * + * A user can update a system if they are the user of it and it has no addresses. + * If it has addresses, at least one of the addresses must have been validated. + * (The assumption is, if a system has multiple addresses, they would be valid, or an admin can remove them.) + * * @param \App\Models\User $user * @param \App\Models\System $system * @return \Illuminate\Auth\Access\Response|bool */ - public function update(User $user, System $system) + public function update(User $user, System $system): bool { - return (! $system->exists) || $system->users->contains($user) || $user->isAdmin(); + // Site Admins can always edit + if ($user->isAdmin()) + return TRUE; + + // If it doesnt exist, then its a false. + if (! $system->exists) + return FALSE; + + return $system->users->contains($user) + && (($system->addresses->count() == 0) || ($system->addresses->where('validated',TRUE)->count())); } } \ No newline at end of file diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index bcbaa4c..c917220 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -113,7 +113,7 @@ text: 'Echomail Statistics' }, subtitle: { - text: '{{ sprintf('%s - %s',\Carbon\Carbon::now()->subMonths(6)->format('Y-m-d'),\Carbon\Carbon::now()->format('Y-m-d')) }}' + text: '{{ sprintf('%s - %s',\Carbon\Carbon::now()->subMonths(6)->startOfMonth()->format('Y-m-d'),\Carbon\Carbon::now()->format('Y-m-d')) }}' }, xAxis: { type: 'category' diff --git a/resources/views/pkt.blade.php b/resources/views/pkt.blade.php index 67af2c2..fe05823 100644 --- a/resources/views/pkt.blade.php +++ b/resources/views/pkt.blade.php @@ -94,7 +94,7 @@ FROM: {!! \App\Classes\FTN\Message::tr($msg->user_from) !!} ({{ $msg->fftn }})