about summary refs log tree commit diff
path: root/laravel/applyedit.php
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2020-11-28 04:17:35 +0000
committerZach DeCook <zachdecook@librem.one>2020-11-28 04:17:35 +0000
commit4b3c5b7646c089e7366bffeb7944d86a78b46266 (patch)
tree7157002943184c26e9f5e2da4062e0c96bf74896 /laravel/applyedit.php
parent60ceebd005844f6ae96d871c959e6cd700753a9f (diff)
downloadprosongsa-4b3c5b7646c089e7366bffeb7944d86a78b46266.tar.gz
* Gemini Editing: use json subject line
Diffstat (limited to 'laravel/applyedit.php')
-rw-r--r--laravel/applyedit.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/laravel/applyedit.php b/laravel/applyedit.php
index 034cca1..993203c 100644
--- a/laravel/applyedit.php
+++ b/laravel/applyedit.php
@@ -13,13 +13,17 @@ for($i = 0; $i < 10; $i++) {
     // TODO: Process these in order?
     $header = imap_header($imap, $number - $i);
     if (strpos($header->to[0]->mailbox, "+songs")){
-        $id = explode(" ", $header->subject)[2];
-        $song = Song::findOrFail($id);
+        $json = json_decode($header->subject);
+        $song = Song::findOrFail($json->id);
         $body = quoted_printable_decode(imap_body($imap, $number - $i));
         $song->text = $body;
+        $song->title = $json->title;
+        $song->author = $json->author;
+        $song->key = $json->key;
+        $song->verse = $json->verse;
         $song->save();
         imap_delete($imap, $number - $i);
-        printf("updated song $id");
+        printf("updated song {$song->id}");
         exit(0);
     }
 }