about summary refs log tree commit diff
path: root/laravel
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
parent60ceebd005844f6ae96d871c959e6cd700753a9f (diff)
downloadprosongsa-4b3c5b7646c089e7366bffeb7944d86a78b46266.tar.gz
* Gemini Editing: use json subject line
Diffstat (limited to 'laravel')
-rw-r--r--laravel/applyedit.php10
-rwxr-xr-xlaravel/public/song.gmi.php8
2 files changed, 14 insertions, 4 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);
     }
 }
diff --git a/laravel/public/song.gmi.php b/laravel/public/song.gmi.php
index 8e3c43b..e4a84d6 100755
--- a/laravel/public/song.gmi.php
+++ b/laravel/public/song.gmi.php
@@ -30,7 +30,13 @@ printf("30 " . Song::inRandomOrder()->first()->id . "\r\n");return;
 
 ```
 
-=> mailto:zachdecook+songs@gmail.com?subject=Edit%20Song%20<?= $song->id ?>&body=<?= rawurlencode($song->text) ?> Edit song
+=> mailto:zachdecook+songs@gmail.com?subject=<?=
+    rawurlencode(json_encode([
+        'id' => $song->id, 'title' => $song->title,
+        'author' => $song->author,
+        'key' => $song->key, 'verse' => $song->verse,
+    ]))
+    ?>&body=<?= rawurlencode($song->text) ?> Edit song
 
 <?php foreach(Song::inRandomOrder()->limit(5)->pluck('title','id') as $id => $title): ?>
 => <?= $id ?> <?= $title ?>