Some message optimisation, added Echomail processing
This commit is contained in:
@@ -2,25 +2,77 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Exceptions\Exception;
|
||||
use Jenssegers\Mongodb\Eloquent\Model;
|
||||
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
|
||||
|
||||
class Echomail extends Model
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Interfaces\Packet;
|
||||
use App\Traits\{MsgID,UseMongo};
|
||||
|
||||
class Echomail extends Model implements Packet
|
||||
{
|
||||
protected $dates = ['date'];
|
||||
protected $fillable = ['date','msgid','from_ftn'];
|
||||
use SoftDeletes,MsgID,UseMongo;
|
||||
|
||||
public function kludges()
|
||||
protected $dates = ['datetime'];
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function fftn()
|
||||
{
|
||||
return $this->belongsToMany(Kludge::class);
|
||||
return $this
|
||||
->setConnection('pgsql')
|
||||
->belongsTo(Address::class)
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function seenbys()
|
||||
{
|
||||
return $this->belongsToMany(Seenby::class,NULL,NULL,'node_id');
|
||||
}
|
||||
/* METHODS */
|
||||
|
||||
public function paths()
|
||||
/**
|
||||
* Return this model as a packet
|
||||
*/
|
||||
public function packet(Address $ao): Message
|
||||
{
|
||||
return $this->belongsToMany(Path::class,NULL,NULL,'node_id');
|
||||
// @todo Dont bundle mail to nodes that have been disabled, or addresses that have been deleted
|
||||
$o = new Message;
|
||||
|
||||
$o->header = [
|
||||
'onode' => $this->fftn->node_id,
|
||||
'dnode' => $ao->node_id,
|
||||
'onet' => $this->fftn->host_id,
|
||||
'dnet' => $ao->host_id,
|
||||
'flags' => 0, // @todo?
|
||||
'cost' => 0,
|
||||
'date'=>$this->datetime->format('d M y H:i:s'),
|
||||
];
|
||||
|
||||
$o->tzutc = $this->datetime->utcOffset($this->tzoffset)->getOffsetString('');
|
||||
$o->user_to = $this->to;
|
||||
$o->user_from = $this->from;
|
||||
$o->subject = $this->subject;
|
||||
$o->echoarea = $this->echoarea;
|
||||
$o->flags = $this->flags;
|
||||
|
||||
$o->kludge->put('mid',$this->id);
|
||||
|
||||
$o->msgid = $this->msgid;
|
||||
if ($this->reply)
|
||||
$o->reply = $this->reply;
|
||||
|
||||
$o->message = $this->msg;
|
||||
|
||||
if ($this->tagline)
|
||||
$o->tagline = $this->tagline;
|
||||
|
||||
if ($this->tearline)
|
||||
$o->tearline = $this->tearline;
|
||||
|
||||
if ($this->origin)
|
||||
$o->origin = $this->origin;
|
||||
|
||||
// @todo SEENBY
|
||||
// @todo PATH
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user