Implemented echoarea/filearea security
This commit is contained in:
@@ -47,6 +47,8 @@ class Address extends Model
|
||||
});
|
||||
}
|
||||
|
||||
protected $visible = ['zone_id','region_id','host_id','node_id','point_id','security'];
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
public function scopeActiveFTN($query)
|
||||
@@ -308,7 +310,12 @@ class Address extends Model
|
||||
*/
|
||||
public function getActiveAttribute(bool $value): bool
|
||||
{
|
||||
return $value && $this->zone->active && $this->zone->domain->active;
|
||||
return $value && $this->getActiveDomainAttribute();
|
||||
}
|
||||
|
||||
public function getActiveDomainAttribute(): bool
|
||||
{
|
||||
return $this->zone->active && $this->zone->domain->active;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,11 +8,41 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Rennokki\QueryCache\Traits\QueryCacheable;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
use App\Traits\{AreaSecurity,ScopeActive};
|
||||
|
||||
/**
|
||||
* Echomail echoareas
|
||||
*
|
||||
* Security thoughts:
|
||||
* + ZCs/RCs/NCs/HUBs carry all echos
|
||||
* + echos for HUBs only (not NODES/POINTs, thus Hub/NC/RC/ZC)
|
||||
* + echos for NCs only (NC/RC/ZC)
|
||||
* + echos for RCs only (RC/ZC)
|
||||
* YYRRRWWW
|
||||
*
|
||||
* Thus YY:
|
||||
* + 0 - not exported
|
||||
* + 1 - Sent to RCs (RW)
|
||||
* + 2 - Sent to NCs as well (RW)
|
||||
* + 3 - Sent to Hubs as well (RW)
|
||||
*
|
||||
* Thus RRR: (Read)
|
||||
* + 0-7
|
||||
* = 0 no read access
|
||||
* = 1-7 minimum access required to perform
|
||||
* Thus WWW: (Write)
|
||||
* + 0-7
|
||||
* = 0 no write access
|
||||
* = 1-7 minimum access required to perform
|
||||
*
|
||||
* - If a node has 0, or an echoarea has 0, then no access to the function
|
||||
* - So if node has 1, and echoarea has 2, no access to function
|
||||
*
|
||||
* @note change "public" to "bot posts"?
|
||||
*/
|
||||
class Echoarea extends Model
|
||||
{
|
||||
use SoftDeletes,ScopeActive,QueryCacheable;
|
||||
use SoftDeletes,ScopeActive,QueryCacheable,AreaSecurity;
|
||||
|
||||
private const CACHE_TIME = 3600;
|
||||
|
||||
|
@@ -96,18 +96,25 @@ final class Echomail extends Model implements Packet
|
||||
}
|
||||
|
||||
// See if we need to export this message.
|
||||
$exportto = $model->echoarea->addresses->pluck('id')->diff($model->set_seenby);
|
||||
if ($model->echoarea->sec_read) {
|
||||
$exportto = ($x=$model
|
||||
->echoarea
|
||||
->addresses
|
||||
->filter(function($item) use ($model) { return $item->security >= $model->echoarea->sec_read; }))
|
||||
->pluck('id')
|
||||
->diff($model->set_seenby);
|
||||
|
||||
if ($exportto->count()) {
|
||||
if ($model->no_export) {
|
||||
Log::debug(sprintf('%s:- NOT processing exporting of message by configuration [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
return;
|
||||
if ($exportto->count()) {
|
||||
if ($model->no_export) {
|
||||
Log::debug(sprintf('%s:- NOT processing exporting of message by configuration [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- Exporting message [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
|
||||
// Save the seenby for the exported systems
|
||||
$model->seenby()->syncWithPivotValues($exportto,['export_at'=>Carbon::now()],FALSE);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- Exporting message [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
|
||||
// Save the seenby for the exported systems
|
||||
$model->seenby()->syncWithPivotValues($exportto,['export_at'=>Carbon::now()],FALSE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -112,18 +112,25 @@ class File extends Model
|
||||
}
|
||||
|
||||
// See if we need to export this message.
|
||||
$exportto = $model->filearea->addresses->pluck('id')->diff($model->set_seenby);
|
||||
if ($model->filearea->sec_read) {
|
||||
$exportto = $model
|
||||
->filearea
|
||||
->addresses
|
||||
->filter(function($item) use ($model) { return $item->security >= $model->echoarea->sec_read; })
|
||||
->pluck('id')
|
||||
->diff($model->set_seenby);
|
||||
|
||||
if ($exportto->count()) {
|
||||
if ($model->no_export) {
|
||||
Log::debug(sprintf('%s:- NOT processing exporting of message by configuration [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
return;
|
||||
if ($exportto->count()) {
|
||||
if ($model->no_export) {
|
||||
Log::debug(sprintf('%s:- NOT processing exporting of message by configuration [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- Exporting file [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
|
||||
// Save the seenby for the exported systems
|
||||
$model->seenby()->syncWithPivotValues($exportto,['export_at'=>Carbon::now()],FALSE);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- Exporting file [%s] to [%s]',self::LOGKEY,$model->id,$exportto->join(',')));
|
||||
|
||||
// Save the seenby for the exported systems
|
||||
$model->seenby()->syncWithPivotValues($exportto,['export_at'=>Carbon::now()],FALSE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
use App\Traits\{AreaSecurity,ScopeActive};
|
||||
|
||||
class Filearea extends Model
|
||||
{
|
||||
use SoftDeletes,ScopeActive;
|
||||
use SoftDeletes,ScopeActive,AreaSecurity;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
|
Reference in New Issue
Block a user