diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 35 |
1 files changed, 34 insertions, 1 deletions
| @@ -2934,6 +2934,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2934 | int proxy = 0; | 2934 | int proxy = 0; |
| 2935 | const char *v; | 2935 | const char *v; |
| 2936 | 2936 | ||
| 2937 | const xs_dict *q_vars = xs_dict_get(req, "q_vars"); | ||
| 2938 | |||
| 2937 | xs *l = xs_split_n(q_path, "/", 2); | 2939 | xs *l = xs_split_n(q_path, "/", 2); |
| 2938 | v = xs_list_get(l, 1); | 2940 | v = xs_list_get(l, 1); |
| 2939 | 2941 | ||
| @@ -2942,6 +2944,23 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2942 | return HTTP_STATUS_NOT_FOUND; | 2944 | return HTTP_STATUS_NOT_FOUND; |
| 2943 | } | 2945 | } |
| 2944 | 2946 | ||
| 2947 | if (strcmp(v, "share-bridge") == 0) { | ||
| 2948 | /* temporary redirect for a post */ | ||
| 2949 | const char *login = xs_dict_get(q_vars, "login"); | ||
| 2950 | const char *content = xs_dict_get(q_vars, "content"); | ||
| 2951 | |||
| 2952 | if (xs_type(login) == XSTYPE_STRING && xs_type(content) == XSTYPE_STRING) { | ||
| 2953 | xs *b64 = xs_base64_enc(content, strlen(content)); | ||
| 2954 | |||
| 2955 | srv_log(xs_fmt("share-bridge for user '%s'", login)); | ||
| 2956 | |||
| 2957 | *body = xs_fmt("%s/%s/share?content=%s", srv_baseurl, login, b64); | ||
| 2958 | return HTTP_STATUS_SEE_OTHER; | ||
| 2959 | } | ||
| 2960 | else | ||
| 2961 | return HTTP_STATUS_NOT_FOUND; | ||
| 2962 | } | ||
| 2963 | |||
| 2945 | uid = xs_dup(v); | 2964 | uid = xs_dup(v); |
| 2946 | 2965 | ||
| 2947 | /* rss extension? */ | 2966 | /* rss extension? */ |
| @@ -2976,7 +2995,6 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2976 | int def_show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); | 2995 | int def_show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); |
| 2977 | int show = def_show; | 2996 | int show = def_show; |
| 2978 | 2997 | ||
| 2979 | const xs_dict *q_vars = xs_dict_get(req, "q_vars"); | ||
| 2980 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) | 2998 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) |
| 2981 | skip = atoi(v), cache = 0, save = 0; | 2999 | skip = atoi(v), cache = 0, save = 0; |
| 2982 | if ((v = xs_dict_get(q_vars, "show")) != NULL) | 3000 | if ((v = xs_dict_get(q_vars, "show")) != NULL) |
| @@ -3490,6 +3508,21 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3490 | } | 3508 | } |
| 3491 | } | 3509 | } |
| 3492 | else | 3510 | else |
| 3511 | if (strcmp(p_path, "share") == 0) { /** direct post **/ | ||
| 3512 | if (!login(&snac, req)) { | ||
| 3513 | *body = xs_dup(uid); | ||
| 3514 | status = HTTP_STATUS_UNAUTHORIZED; | ||
| 3515 | } | ||
| 3516 | else { | ||
| 3517 | const char *content = xs_dict_get(q_vars, "content"); | ||
| 3518 | |||
| 3519 | // srv_log(xs_fmt("---> SHARE %s", content)); | ||
| 3520 | *body = xs_fmt("%s/admin", snac.actor); | ||
| 3521 | *b_size = strlen(*body); | ||
| 3522 | status = HTTP_STATUS_SEE_OTHER; | ||
| 3523 | } | ||
| 3524 | } | ||
| 3525 | else | ||
| 3493 | status = HTTP_STATUS_NOT_FOUND; | 3526 | status = HTTP_STATUS_NOT_FOUND; |
| 3494 | 3527 | ||
| 3495 | user_free(&snac); | 3528 | user_free(&snac); |