mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 05:37:33 -05:00 
			
		
		
		
	
						commit
						c04617aad1
					
				@ -24,6 +24,8 @@ use App\Models\Invoice;
 | 
			
		||||
use App\Models\InvoiceInvitation;
 | 
			
		||||
use App\Models\Payment;
 | 
			
		||||
use App\Models\Paymentable;
 | 
			
		||||
use App\Models\QuoteInvitation;
 | 
			
		||||
use App\Models\RecurringInvoiceInvitation;
 | 
			
		||||
use App\Utils\Ninja;
 | 
			
		||||
use Exception;
 | 
			
		||||
use Illuminate\Console\Command;
 | 
			
		||||
@ -198,7 +200,7 @@ class CheckData extends Command
 | 
			
		||||
                    ->where('id', '=', $contact->id)
 | 
			
		||||
                    ->whereNull('contact_key')
 | 
			
		||||
                    ->update([
 | 
			
		||||
                        'contact_key' => str_random(config('ninja.key_length')),
 | 
			
		||||
                        'contact_key' => Str::random(config('ninja.key_length')),
 | 
			
		||||
                    ]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -319,6 +321,10 @@ class CheckData extends Command
 | 
			
		||||
    private function checkEntityInvitations()
 | 
			
		||||
    {
 | 
			
		||||
    
 | 
			
		||||
    RecurringInvoiceInvitation::where('deleted_at',"0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
 | 
			
		||||
    InvoiceInvitation::where('deleted_at',"0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
 | 
			
		||||
    QuoteInvitation::where('deleted_at',"0000-00-00 00:00:00.000000")->withTrashed()->update(['deleted_at' => null]);
 | 
			
		||||
 | 
			
		||||
        $entities = ['invoice', 'quote', 'credit', 'recurring_invoice'];
 | 
			
		||||
 | 
			
		||||
        foreach($entities as $entity)
 | 
			
		||||
@ -328,8 +334,8 @@ class CheckData extends Command
 | 
			
		||||
 | 
			
		||||
        $entities = DB::table($table)
 | 
			
		||||
                    ->leftJoin($invitation_table, function ($join) use($invitation_table, $table, $entity){
 | 
			
		||||
                        $join->on("{$invitation_table}.{$entity}_id", '=', "{$table}.id")
 | 
			
		||||
                             ->whereNull("{$invitation_table}.deleted_at");
 | 
			
		||||
                        $join->on("{$invitation_table}.{$entity}_id", '=', "{$table}.id");
 | 
			
		||||
                             // ->whereNull("{$invitation_table}.deleted_at");
 | 
			
		||||
                    })
 | 
			
		||||
                    ->groupBy("{$table}.id", "{$table}.user_id", "{$table}.company_id", "{$table}.client_id")
 | 
			
		||||
                    ->havingRaw("count({$invitation_table}.id) = 0")
 | 
			
		||||
@ -359,7 +365,13 @@ class CheckData extends Command
 | 
			
		||||
            $invitation->{$entity_key} = $entity->id;
 | 
			
		||||
            $invitation->client_contact_id = ClientContact::whereClientId($entity->client_id)->first()->id;
 | 
			
		||||
            $invitation->key = Str::random(config('ninja.key_length'));
 | 
			
		||||
 | 
			
		||||
            try{
 | 
			
		||||
                $invitation->save();
 | 
			
		||||
            }
 | 
			
		||||
            catch(\Exception $e){
 | 
			
		||||
                $invitation = null;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ class S3Cleanup extends Command
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $description = 'Remove orphan folders';
 | 
			
		||||
    protected $description = 'Remove orphan folders/files';
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a new command instance.
 | 
			
		||||
@ -54,7 +54,11 @@ class S3Cleanup extends Command
 | 
			
		||||
                if(!in_array($dir, $merged))
 | 
			
		||||
                {
 | 
			
		||||
                    $this->logMessage("Deleting $dir");
 | 
			
		||||
 | 
			
		||||
                    /* Ensure we are not deleting the root folder */
 | 
			
		||||
                    if(strlen($dir) > 1)
 | 
			
		||||
                        Storage::disk(config('filesystems.default'))->deleteDirectory($dir);
 | 
			
		||||
                    
 | 
			
		||||
                }
 | 
			
		||||
            }        
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,8 @@ class Kernel extends ConsoleKernel
 | 
			
		||||
 | 
			
		||||
            $schedule->job(new AdjustEmailQuota)->dailyAt('23:00')->withoutOverlapping();
 | 
			
		||||
            $schedule->job(new SendFailedEmails)->daily()->withoutOverlapping();
 | 
			
		||||
            $schedule->command('ninja:check-data --database=db-ninja-02')->daily()->withoutOverlapping();
 | 
			
		||||
            $schedule->command('ninja:check-data --database=db-ninja-02')->dailyAt('00:15')->withoutOverlapping();
 | 
			
		||||
            $schedule->command('ninja:s3-cleanup')->dailyAt('23:15')->withoutOverlapping();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user