summary refs log tree commit diff stats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/service.raku26
1 files changed, 25 insertions, 1 deletions
diff --git a/server/service.raku b/server/service.raku
index 638989c..1ccbb85 100644
--- a/server/service.raku
+++ b/server/service.raku
@@ -67,7 +67,7 @@ my $application = route {
                 my Str @messages;
                 @messages.push("Max file size exceeded")
                     if $img.body-blob.bytes > 2097152; # 1024 * 1024 * 2
-                @messages.push("Only png/jpeg allowed");
+                @messages.push("Only png/jpeg allowed")
                     if $img.content-type ne "image/png"|"image/jpeg";
 
                 $stored = False if @messages.elems;
@@ -86,6 +86,30 @@ my $application = route {
         }
     }
 
+    get -> 'smile', $id {
+        my IO() $user-store = "%s/%s".sprintf: $store, $id;
+
+        my $img;
+        if "$user-store/images".IO.d {
+            put "huh";
+            my @imgs = dir("$user-store/images").grep(*.f);
+            if @imgs.elems {
+                $img = @imgs.pick(1).first;
+            } else {
+                response.status = 406;
+            }
+        } else {
+            response.status = 404;
+        }
+
+        if $img {
+            static $img;
+            $img.unlink;
+        } else {
+            content 'text/plain', '';
+        }
+    }
+
     # Serving static assets.
     get -> 'js', *@path { static 'dist/js', @path; }
     get -> 'css', *@path { static 'dist/css', @path; }