about summary refs log tree commit diff
path: root/laravel/applyedit.php
diff options
context:
space:
mode:
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);
     }
 }