Support merging addresses when both src/dst addresses are in the seenby
This commit is contained in:
parent
03ca4c10b1
commit
2edc41b11e
@ -16,7 +16,7 @@ use Illuminate\Support\ViewErrorBag;
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Http\Requests\{AddressMerge,AreafixRequest,SystemRegister};
|
||||
use App\Jobs\AddressPoll;
|
||||
use App\Models\{Address,Echoarea,Filearea,Netmail,Setup,System,Zone};
|
||||
use App\Models\{Address,Echoarea,Echomail,Filearea,Netmail,Setup,System,Zone};
|
||||
use App\Notifications\Netmails\AddressLink;
|
||||
use App\Rules\{FidoInteger,TwoByteInteger};
|
||||
|
||||
@ -336,6 +336,24 @@ class SystemController extends Controller
|
||||
if ($request->validated()) {
|
||||
DB::beginTransaction();
|
||||
|
||||
// Find all the echomails that have both seenby's
|
||||
$x = Echomail::select(['id'])
|
||||
->join('echomail_seenby',['echomail_seenby.echomail_id'=>'echomails.id'])
|
||||
->whereIn('address_id',[$request->src])
|
||||
->distinct()
|
||||
->with(['seenby:id'])
|
||||
->get()
|
||||
->filter(function($item) use ($request) {
|
||||
return $item->seenby->contains($request->dst) && $item->seenby->contains($request->src);
|
||||
});
|
||||
|
||||
// If the Echomail has both source and dest, delete the src
|
||||
if ($x->count())
|
||||
DB::table('echomail_seenby')
|
||||
->where('address_id',$request->src)
|
||||
->whereIn('echomail_id',$x->pluck('id'))
|
||||
->delete();
|
||||
|
||||
// Find all echomail seenbys
|
||||
$x = DB::update('update echomail_seenby set address_id=? where address_id=?',[$request->dst,$request->src]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user