Changes to Authorisation for users to edit systems, minor cosmetic fixes and more logging
This commit is contained in:
parent
10afd6f3a4
commit
fa2ac9a656
@ -219,6 +219,8 @@ class Message extends FTNBase
|
|||||||
*/
|
*/
|
||||||
public static function parseMessage(string $msg,Zone $zone=NULL): self
|
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);
|
$o = new self($zone);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -422,10 +422,14 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
*/
|
*/
|
||||||
private function parseMessage(string $message): void
|
private function parseMessage(string $message): void
|
||||||
{
|
{
|
||||||
|
Log::info(sprintf('%s:Processing message [%d] bytes',self::LOGKEY,strlen($message)));
|
||||||
|
|
||||||
$msg = Message::parseMessage($message,$this->zone);
|
$msg = Message::parseMessage($message,$this->zone);
|
||||||
|
|
||||||
// If the message is invalid, we'll ignore it
|
// If the message is invalid, we'll ignore it
|
||||||
if ($msg->errors) {
|
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 the from address doenst exist, we'll create a new entry
|
||||||
if ($msg->errors->messages()->has('from')) {
|
if ($msg->errors->messages()->has('from')) {
|
||||||
$e = NULL;
|
$e = NULL;
|
||||||
|
@ -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)
|
// @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) {
|
static::created(function($model) {
|
||||||
if (! $model->echoarea_id) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,25 @@ class SystemPolicy
|
|||||||
/**
|
/**
|
||||||
* Determine whether the user can update the model.
|
* 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\User $user
|
||||||
* @param \App\Models\System $system
|
* @param \App\Models\System $system
|
||||||
* @return \Illuminate\Auth\Access\Response|bool
|
* @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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -113,7 +113,7 @@
|
|||||||
text: 'Echomail Statistics'
|
text: 'Echomail Statistics'
|
||||||
},
|
},
|
||||||
subtitle: {
|
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: {
|
xAxis: {
|
||||||
type: 'category'
|
type: 'category'
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
FROM: <strong class="highlight">{!! \App\Classes\FTN\Message::tr($msg->user_from) !!}</strong> (<strong class="highlight">{{ $msg->fftn }}</strong>)
|
FROM: <strong class="highlight">{!! \App\Classes\FTN\Message::tr($msg->user_from) !!}</strong> (<strong class="highlight">{{ $msg->fftn }}</strong>)
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
TO: <strong class="highlight">{!! \App\Classes\FTN\Message::tr($msg->user_to) !!}</strong> XX(<strong class="highlight">{{ $msg->tftn }}</strong>)
|
TO: <strong class="highlight">{!! \App\Classes\FTN\Message::tr($msg->user_to) !!}</strong>@if($msg->isNetmail()) (<strong class="highlight">{{ $msg->tftn }}</strong>) @endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user