QoL: alert the user if they attempt to download a theme that has not been approved.

Stopgap solution; TP does not want to expose approval status in headers for security reasons.
This commit is contained in:
Dylan G
2020-12-24 22:58:52 +00:00
parent 7871225999
commit 4720a49923

View File

@@ -1002,11 +1002,15 @@ redirect: // goto here if we need to redirect
return _header.result_code; return _header.result_code;
case HTTP_NOT_FOUND: case HTTP_NOT_FOUND:
case HTTP_GONE: ; case HTTP_GONE: ;
// TODO: check if we're looking at a TP URL, if we are, suggest that it might be missing
const char * http_error = parse == HTTP_NOT_FOUND ? "404 Not Found" : "410 Gone"; const char * http_error = parse == HTTP_NOT_FOUND ? "404 Not Found" : "410 Gone";
DEBUG("HTTP %s; URL: %s\n", http_error, url); DEBUG("HTTP %s; URL: %s\n", http_error, url);
if (strstr(url, THEMEPLAZA_BASE_URL) && parse == HTTP_NOT_FOUND)
throw_error("HTTP 404 Not Found\nHas this theme been approved?", ERROR_LEVEL_WARNING);
else
{
snprintf(err_buf, 0x69, "HTTP %s\nCheck that the URL is correct.", http_error); snprintf(err_buf, 0x69, "HTTP %s\nCheck that the URL is correct.", http_error);
throw_error(err_buf, ERROR_LEVEL_WARNING); throw_error(err_buf, ERROR_LEVEL_WARNING);
}
return httpcCloseContext(&context); return httpcCloseContext(&context);
case HTTP_UNAUTHORIZED: case HTTP_UNAUTHORIZED:
case HTTP_FORBIDDEN: case HTTP_FORBIDDEN:
@@ -1021,7 +1025,7 @@ redirect: // goto here if we need to redirect
return httpcCloseContext(&context); return httpcCloseContext(&context);
case HTTP_URI_TOO_LONG: case HTTP_URI_TOO_LONG:
DEBUG("HTTP 414; URL is too long, maybe too many redirects?\n"); DEBUG("HTTP 414; URL is too long, maybe too many redirects?\n");
throw_error("HTTP 414 URI Too Long\nThe QR code points to a really long URL.\nContact the site administrator.", ERROR_LEVEL_WARNING); throw_error("HTTP 414 URI Too Long\nThe QR code points to a really long URL.\nDownload the file directly.", ERROR_LEVEL_WARNING);
return httpcCloseContext(&context); return httpcCloseContext(&context);
case HTTP_IM_A_TEAPOT: case HTTP_IM_A_TEAPOT:
DEBUG("HTTP 418 I'm a teapot\n"); DEBUG("HTTP 418 I'm a teapot\n");