about summary refs log tree commit diff
path: root/laravel/applyedit.php
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-09-28 16:05:12 +0000
committerZach DeCook <zachdecook@librem.one>2021-09-28 16:05:12 +0000
commit753593fe0d25a5cc58ca84fbbccc24bd9c6e6e1e (patch)
treecd7209b54ee4108ad943bc4db87746e7ab38e231 /laravel/applyedit.php
parent0586163907a153ebe1d506d8040aa574a0b6e0f3 (diff)
downloadprosongsa-753593fe0d25a5cc58ca84fbbccc24bd9c6e6e1e.tar.gz
misc gemini additions
Diffstat (limited to 'laravel/applyedit.php')
-rwxr-xr-xlaravel/applyedit.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/laravel/applyedit.php b/laravel/applyedit.php
index b9aa619..bd9f296 100755
--- a/laravel/applyedit.php
+++ b/laravel/applyedit.php
@@ -8,12 +8,20 @@ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
 use App\Song;
 
 $imap = imap_open($mailbox, $username, $password);
+if (!$imap){
+    printf("no imap :(");
+    exit(1);
+}
 $check = imap_check($imap); $number = $check->Nmsgs;
+if (!$check){
+    printf("no check :(");
+    exit(1);
+}
 // Just check the newest 10 messages.
-for($i = 0; $i < 10; $i++) {
+for($i = 0; $i < 30; $i++) {
     // TODO: Process these in order?
     $header = imap_header($imap, $number - $i);
-    if (strpos($header->to[0]->mailbox, "+songs")){
+    if (isset($header->to[0]) && strpos($header->to[0]->mailbox, "+songs")){
         $json = json_decode($header->subject);
         $song = Song::findOrFail($json->id);
         $body = quoted_printable_decode(imap_body($imap, $number - $i));
@@ -25,7 +33,6 @@ for($i = 0; $i < 10; $i++) {
         $song->save();
         imap_delete($imap, $number - $i);
         printf("updated song {$song->id}");
-        exit(0);
     }
 }
 exit(0);