commit 306f5bd

default  ·  2023-02-15 08:08:27 +0000 UTC
parent d3da67e
Added support for receiving un uploaded avatar.
1 files changed,  +19, -0
M html.c
M html.c
+19, -0
 1@@ -1615,6 +1615,25 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
 2             snac.config = xs_dict_set(snac.config, "purge_days", days);
 3         }
 4 
 5+        /* avatar upload */
 6+        char *avatar_file = xs_dict_get(p_vars, "avatar_file");
 7+        if (!xs_is_null(avatar_file) && xs_type(avatar_file) == XSTYPE_LIST) {
 8+            char *fn = xs_list_get(avatar_file, 0);
 9+
10+            if (*fn != '\0') {
11+                char *ext = strrchr(fn, '.');
12+                xs *id    = xs_fmt("avatar%s", ext);
13+                xs *url   = xs_fmt("%s/s/%s", snac.actor, id);
14+                int fo    = xs_number_get(xs_list_get(avatar_file, 1));
15+                int fs    = xs_number_get(xs_list_get(avatar_file, 2));
16+
17+                /* store */
18+                static_put(&snac, id, payload + fo, fs);
19+
20+                snac.config = xs_dict_set(snac.config, "avatar", url);
21+            }
22+        }
23+
24         /* password change? */
25         if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL &&
26             (p2 = xs_dict_get(p_vars, "passwd2")) != NULL &&