]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5898 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Apr 2023 14:24:54 +0000 (16:24 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 28 Apr 2023 14:24:54 +0000 (16:24 +0200)
app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/SocialImageOperation.php
app/Jobs/Maintenance/CheckPublicationsHashAndCid.php [new file with mode: 0644]
app/Models/FluidbookPublication.php
resources/fluidbookpublication/social_screenshot/social_screenshot.js

index 47d3aa619b1881d25cfc78261d366bbb64bf0806..d4520467fda265e0d3b0d44600e8a93527bda08e 100644 (file)
@@ -89,7 +89,7 @@ trait SocialImageOperation
                 if (!file_exists($lock) || filemtime($lock) < time() - 3600) {
                     touch($lock);
 
-                    $url = 'https://workshop.fluidbook.com/viewerh/' . $id . '_' . $fluidbook->hash . '_' . time() . '/?nointerface=1';
+                    $url = 'https://toolbox.fluidbook.com/fluidbook-publication/preview/' . $id . '_' . $fluidbook->hash . '_' . time() . '/?nointerface=1';
                     if ((file_exists($res) && filemtime($res) < $limit) || isset($_GET['forcecompile'])) {
                         $url .= '&force=1';
                     }
@@ -107,6 +107,7 @@ trait SocialImageOperation
                     $cl->setArg('dest', $res);
                     $cl->setArg('url', $url);
                     $cl->execute();
+                    $cl->debug();
                     unlink($lock);
                 }
             }
diff --git a/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php b/app/Jobs/Maintenance/CheckPublicationsHashAndCid.php
new file mode 100644 (file)
index 0000000..5ddce2d
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Jobs\Maintenance;
+
+use App\Jobs\Base;
+use App\Models\FluidbookPublication;
+use App\Models\Traits\CheckHash;
+
+class CheckPublicationsHashAndCid extends Base
+{
+    public function handle()
+    {
+        /** @var FluidbookPublication $fluidbook */
+        foreach (FluidbookPublication::withoutGlobalScopes()->whereNull('hash')->orWhere('hash', '')->orWhereNull('cid')->orWhere('cid', '')->get() as $fluidbook) {
+            $fluidbook->save();
+            echo 'Process ' . $fluidbook->id . "\n";
+        }
+    }
+}
index f4ab0910ea3a585489af32c9024ef94e6a226e3a..995823380f9c7db2082777df2035a3a88655c9c1 100644 (file)
@@ -42,6 +42,7 @@ use Cubist\Util\Json;
 use Cubist\Util\Str;
 use Datetime;
 use Illuminate\Support\Facades\Artisan;
+use Illuminate\Support\Facades\Log;
 
 // __('!!Paramètres des fluidbooks')
 class FluidbookPublication extends ToolboxSettingsModel
@@ -251,22 +252,28 @@ class FluidbookPublication extends ToolboxSettingsModel
     protected function setComposedAttributes()
     {
         /** @var \App\Models\User $owner */
-        $owner = \App\Models\User::find($this->owner);
+        $owner = \App\Models\User::withoutGlobalScopes()->find($this->owner);
         if (null === $owner) {
             $this->owner = 1;
             $this->saveQuietly();
-            $owner = \App\Models\User::find(1);
+            $owner = \App\Models\User::withoutGlobalScopes()->find(1);
         }
         /** @var Company $company */
-        $company = Company::withoutGlobalScopes()->find($owner->company);
+        if (null !== $owner) {
+            $company = Company::withoutGlobalScopes()->find($owner->company);
 
-        $this->admin = $company->admin;
-        $this->super_admin = '';
-        $this->owner_company_name = $company->company_with_name;
-        $this->owner_name = $owner->name;
+            $this->admin = $company->admin;
+            $this->super_admin = '';
+            $this->owner_company_name = $company->company_with_name;
+            $this->owner_name = $owner->name;
+
+        } else {
+            Log::warning('Fluidbook ' . $this->id . ' has no owner : ' . $this->owner);
+        }
         $this->invoicable = '';
         $this->invoicable_company = '';
         $this->extranet_project = '';
+
         $this->c_title = $this->title;
         $this->c_pages = count($this->composition);
     }
index 8beb7d57b620612bbb6affa588b44fdcdefc4fee..14956cc0722c64023104f96c51a03715e583c03c 100644 (file)
@@ -20,7 +20,7 @@ const optionDefinitions = [
         executablePath: 'google-chrome-stable',
     });
     const page = await browser.newPage();
-    page.on('console', msg => console.log('PAGE LOG:', msg._text));
+    page.on('console', msg => console.log('PAGE LOG:', msg));
     await page.setViewport({
         width: options.width / options.scale,
         height: options.height / options.scale,