Compare commits
No commits in common. "c8e4078b35f7be2c1d3a57a85b26d4a2b8b2c9cf" and "30146556f518117622541a1e578e9ad660796174" have entirely different histories.
c8e4078b35
...
30146556f5
12 changed files with 16 additions and 40 deletions
|
@ -58,15 +58,8 @@ public partial class MetaController(Config config) : ApiControllerBase
|
|||
}
|
||||
|
||||
string path = Path.Join(Directory.GetCurrentDirectory(), "static-pages", $"{page}.md");
|
||||
try
|
||||
{
|
||||
string text = await System.IO.File.ReadAllTextAsync(path, ct);
|
||||
return Ok(text);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
throw new ApiError.NotFound("Page not found", code: ErrorCode.PageNotFound);
|
||||
}
|
||||
string text = await System.IO.File.ReadAllTextAsync(path, ct);
|
||||
return Ok(text);
|
||||
}
|
||||
|
||||
[HttpGet("/api/v2/coffee")]
|
||||
|
|
|
@ -164,7 +164,6 @@ public enum ErrorCode
|
|||
GenericApiError,
|
||||
UserNotFound,
|
||||
MemberNotFound,
|
||||
PageNotFound,
|
||||
AccountAlreadyLinked,
|
||||
LastAuthMethod,
|
||||
InvalidReportTarget,
|
||||
|
|
|
@ -21,8 +21,12 @@ Sentry.init({
|
|||
});
|
||||
|
||||
export const handleError: HandleServerError = async ({ error, status, message }) => {
|
||||
// as far as i know, sentry IDs are just UUIDs with the dashes removed. use those here as well
|
||||
let id = crypto.randomUUID().replaceAll("-", "");
|
||||
|
||||
if (error instanceof ApiError) {
|
||||
return {
|
||||
error_id: id,
|
||||
status: error.raw?.status || status,
|
||||
message: error.raw?.message || "Unknown error",
|
||||
code: error.code,
|
||||
|
@ -30,11 +34,11 @@ export const handleError: HandleServerError = async ({ error, status, message })
|
|||
}
|
||||
|
||||
if (status >= 400 && status <= 499) {
|
||||
return { status, message, code: ErrorCode.GenericApiError };
|
||||
return { error_id: id, status, message, code: ErrorCode.GenericApiError };
|
||||
}
|
||||
|
||||
// client errors and backend API errors just clog up sentry, so we don't send those.
|
||||
const id = Sentry.captureException(error, {
|
||||
id = Sentry.captureException(error, {
|
||||
mechanism: {
|
||||
type: "sveltekit",
|
||||
handled: false,
|
||||
|
|
|
@ -43,7 +43,6 @@ export enum ErrorCode {
|
|||
MemberNotFound = "MEMBER_NOT_FOUND",
|
||||
AccountAlreadyLinked = "ACCOUNT_ALREADY_LINKED",
|
||||
LastAuthMethod = "LAST_AUTH_METHOD",
|
||||
PageNotFound = "PAGE_NOT_FOUND",
|
||||
// This code isn't actually returned by the API
|
||||
Non204Response = "(non 204 response)",
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ export default function errorDescription(t: TranslateFn, code: ErrorCode): strin
|
|||
return t("error.account-already-linked");
|
||||
case ErrorCode.LastAuthMethod:
|
||||
return t("error.last-auth-method");
|
||||
case ErrorCode.PageNotFound:
|
||||
return t("error.page-not-found");
|
||||
case ErrorCode.Non204Response:
|
||||
return t("error.generic-error");
|
||||
}
|
||||
|
|
|
@ -120,8 +120,7 @@
|
|||
"400-description": "Something went wrong with your request. This error should never land you on this page, so it's probably a bug.",
|
||||
"500-description": "Something went wrong on the server. Please try again later.",
|
||||
"unknown-status-description": "Something went wrong, but we're not sure what. Please try again.",
|
||||
"error-id": "If you report this error to the developers, please give them this ID:",
|
||||
"page-not-found": "No page exists at this URL."
|
||||
"error-id": "If you report this error to the developers, please give them this ID:"
|
||||
},
|
||||
"settings": {
|
||||
"general-information-tab": "General information",
|
||||
|
@ -322,7 +321,6 @@
|
|||
"required": "Required"
|
||||
},
|
||||
"alert": {
|
||||
"auth-method-remove-success": "Successfully unlinked account!",
|
||||
"auth-required": "You must log in to access this page."
|
||||
"auth-method-remove-success": "Successfully unlinked account!"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@ export const load = async ({ url, fetch, cookies }) => {
|
|||
fetch,
|
||||
cookies,
|
||||
});
|
||||
return { reports, url: url.toString(), includeClosed, byReporter, byTarget, before, after };
|
||||
return { reports, url: url.toString(), byReporter, byTarget, before, after };
|
||||
};
|
||||
|
|
|
@ -18,14 +18,6 @@
|
|||
return url.toString();
|
||||
};
|
||||
|
||||
const addClosed = () => {
|
||||
const url = new URL(data.url);
|
||||
if (!data.includeClosed) url.searchParams.set("include-closed", "true");
|
||||
else url.searchParams.delete("include-closed");
|
||||
|
||||
return url.toString();
|
||||
};
|
||||
|
||||
const addTarget = (id: string | null) => {
|
||||
const url = new URL(data.url);
|
||||
if (id) url.searchParams.set("by-target", id);
|
||||
|
@ -64,11 +56,6 @@
|
|||
{#if data.byReporter}
|
||||
<li>Filtering by reporter (<a href={addReporter(null)}>clear</a>)</li>
|
||||
{/if}
|
||||
{#if data.includeClosed}
|
||||
<li>Showing all reports (<a href={addClosed()}>only show open reports</a>)</li>
|
||||
{:else}
|
||||
<li>Showing open reports (<a href={addClosed()}>show all reports</a>)</li>
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
{#if data.before}
|
||||
|
|
|
@ -2,15 +2,15 @@ import { isRedirect, redirect } from "@sveltejs/kit";
|
|||
|
||||
import { apiRequest } from "$api";
|
||||
import type { AuthResponse, AuthUrls } from "$api/models/auth";
|
||||
import { alertKey, setToken } from "$lib";
|
||||
import { setToken } from "$lib";
|
||||
import ApiError, { ErrorCode } from "$api/error";
|
||||
|
||||
export const load = async ({ fetch, parent, url }) => {
|
||||
export const load = async ({ fetch, parent }) => {
|
||||
const parentData = await parent();
|
||||
if (parentData.meUser) redirect(303, `/@${parentData.meUser.username}`);
|
||||
|
||||
const urls = await apiRequest<AuthUrls>("POST", "/auth/urls", { fetch, isInternal: true });
|
||||
return { urls, alertKey: alertKey(url) };
|
||||
return { urls };
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import { t } from "$lib/i18n";
|
||||
import { enhance } from "$app/forms";
|
||||
import ErrorAlert from "$components/ErrorAlert.svelte";
|
||||
import UrlAlert from "$components/URLAlert.svelte";
|
||||
|
||||
type Props = { data: PageData; form: ActionData };
|
||||
let { data, form }: Props = $props();
|
||||
|
@ -14,7 +13,6 @@
|
|||
</svelte:head>
|
||||
|
||||
<div class="container">
|
||||
<UrlAlert {data} />
|
||||
<div class="row">
|
||||
{#if form?.error}
|
||||
<ErrorAlert error={form.error} />
|
||||
|
|
|
@ -2,5 +2,5 @@ import { redirect } from "@sveltejs/kit";
|
|||
|
||||
export const load = async ({ parent }) => {
|
||||
const { meUser } = await parent();
|
||||
if (!meUser) redirect(303, "/auth/log-in?alert=auth-required");
|
||||
if (!meUser) redirect(303, "/auth/log-in");
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import { redirect } from "@sveltejs/kit";
|
|||
|
||||
export const load = async ({ parent }) => {
|
||||
const data = await parent();
|
||||
if (!data.meUser) redirect(303, "/auth/log-in?alert=auth-required");
|
||||
if (!data.meUser) redirect(303, "/auth/log-in");
|
||||
|
||||
return { user: data.meUser!, token: data.token! };
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue