Fixes to message processing, now that we are using cockroachdb
This commit is contained in:
@@ -122,12 +122,28 @@ class Address extends Model
|
||||
->with(['zone.domain']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Echoareas this address is subscribed to
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function echoareas()
|
||||
{
|
||||
return $this->belongsToMany(Echoarea::class)
|
||||
->withPivot(['subscribed']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Echomails that this address has seen
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function echomails()
|
||||
{
|
||||
return $this->belongsToMany(Echomail::class,'echomail_seenby')
|
||||
->withPivot(['sent_at','packet']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Who we send this systems mail to.
|
||||
*
|
||||
@@ -346,9 +362,7 @@ class Address extends Model
|
||||
*/
|
||||
public function echomailWaiting(): Collection
|
||||
{
|
||||
return Echomail::select(['echomails.*'])
|
||||
->join('echomail_seenby',['echomail_seenby.echomail_id'=>'echomails.id'])
|
||||
->where('echomail_seenby.address_id',$this->id)
|
||||
return $this->echomails()
|
||||
->whereNull('echomail_seenby.sent_at')
|
||||
->whereNotNull('echomail_seenby.export_at')
|
||||
->get();
|
||||
@@ -372,6 +386,7 @@ class Address extends Model
|
||||
->whereIn('echomail_id',$x->pluck('id'))
|
||||
->where('address_id',$this->id)
|
||||
->whereNull('sent_at')
|
||||
->whereNull('packet')
|
||||
->whereNotNull('echomail_seenby.export_at')
|
||||
->update(['sent_at'=>Carbon::now(),'packet'=>$pkt->name]);
|
||||
}
|
||||
@@ -411,15 +426,9 @@ class Address extends Model
|
||||
{
|
||||
$o = new Packet($this);
|
||||
|
||||
foreach ($c as $oo) {
|
||||
foreach ($c as $oo)
|
||||
$o->addMail($oo->packet($this));
|
||||
|
||||
$oo->packet = $o->name;
|
||||
$oo->sent = TRUE;
|
||||
$oo->sent_at = Carbon::now();
|
||||
$oo->save();
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user