 86c369d7ce
			
		
	
	
		86c369d7ce
		
			
		
	
	
	
	
		
			
			* feat: First Webhook PoC draft * feat: Dispatch Webhooks PoC * fix: typo in webhook configuration scope * Update 2024_04_21_162552_create_webhooks_table.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update 2024_04_21_162552_create_webhooks_table.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update 2024_04_21_162544_create_webhook_configurations_table.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update 2024_04_21_162544_create_webhook_configurations_table.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhooks.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhooksJob.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhookForConfiguration.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhookForConfiguration.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhookForConfiguration.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhooksJob.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhooksJob.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * Update DispatchWebhooksJob.php Co-authored-by: Lance Pioch <lancepioch@gmail.com> * chore: Implement Webhook Event Discovery * we got a test working for webhooks * WIP * Something is working! * More tests * clean up the tests now that they are passing * WIP * Don't use model specific events * WIP * WIP * WIP * WIP * WIP * Do it sync * Reset these * Don't need restored event type * Deleted some unused jobs * Find custom Events * Remove observers * Add custom event test * Run Pint * Add caching * Don't cache every single event * Fix tests * Run Pint * Phpstan fixes * Pint fix * Test fixes * Middleware unit test fix * Pint fixes * Remove index not working for older dbs * Use facade instead --------- Co-authored-by: Pascale Beier <mail@pascalebeier.de> Co-authored-by: Lance Pioch <lancepioch@gmail.com> Co-authored-by: Vehikl <go@vehikl.com>
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Database\Seeders;
 | |
| 
 | |
| use App\Models\Egg;
 | |
| use Exception;
 | |
| use Illuminate\Database\Seeder;
 | |
| use Illuminate\Http\UploadedFile;
 | |
| use App\Services\Eggs\Sharing\EggImporterService;
 | |
| 
 | |
| class EggSeeder extends Seeder
 | |
| {
 | |
|     protected EggImporterService $importerService;
 | |
| 
 | |
|     /**
 | |
|      * @var string[]
 | |
|      */
 | |
|     public static array $imports = [
 | |
|         'Minecraft',
 | |
|         'Source Engine',
 | |
|         'Voice Servers',
 | |
|         'Rust',
 | |
|     ];
 | |
| 
 | |
|     /**
 | |
|      * EggSeeder constructor.
 | |
|      */
 | |
|     public function __construct(
 | |
|         EggImporterService $importerService
 | |
|     ) {
 | |
|         $this->importerService = $importerService;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Run the egg seeder.
 | |
|      */
 | |
|     public function run(): void
 | |
|     {
 | |
|         foreach (static::$imports as $import) {
 | |
|             $this->parseEggFiles($import);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Loop through the list of egg files and import them.
 | |
|      */
 | |
|     protected function parseEggFiles($name): void
 | |
|     {
 | |
|         $files = new \DirectoryIterator(database_path('Seeders/eggs/' . kebab_case($name)));
 | |
| 
 | |
|         $this->command->alert('Updating Eggs for: ' . $name);
 | |
|         /** @var \DirectoryIterator $file */
 | |
|         foreach ($files as $file) {
 | |
|             if (!$file->isFile() || !$file->isReadable()) {
 | |
|                 continue;
 | |
|             }
 | |
| 
 | |
|             try {
 | |
|                 $decoded = json_decode(file_get_contents($file->getRealPath()), true, 512, JSON_THROW_ON_ERROR);
 | |
|             } catch (Exception) {
 | |
|                 continue;
 | |
|             }
 | |
| 
 | |
|             $file = new UploadedFile($file->getPathname(), $file->getFilename(), 'application/json');
 | |
| 
 | |
|             $egg = Egg::query()
 | |
|                 ->where('author', $decoded['author'])
 | |
|                 ->where('name', $decoded['name'])
 | |
|                 ->first();
 | |
| 
 | |
|             if ($egg instanceof Egg) {
 | |
|                 $this->importerService->fromFile($file, $egg);
 | |
|                 $this->command->info('Updated ' . $decoded['name']);
 | |
|             } else {
 | |
|                 $this->importerService->fromFile($file);
 | |
|                 $this->command->comment('Created ' . $decoded['name']);
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         $this->command->line('');
 | |
|     }
 | |
| }
 |