Skip to content

Commit

Permalink
refactor: remove old, unused DNS verification code.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Dec 3, 2024
1 parent 63be355 commit 2a48968
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 51 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test": "vitest"
},
"devDependencies": {
"@atproto/api": "^0.13.18",
"@codemirror/lang-markdown": "^6.3.1",
"@codemirror/language": "^6.10.4",
"@dicebear/collection": "^9.2.2",
Expand Down Expand Up @@ -50,7 +51,8 @@
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.46.0",
"keyv": "^4.5.4",
"fast-xml-parser": "^4.5.0",
"keyv": "^5.2.1",
"leaf-proto": "workspace:*",
"linkedom": "^0.18.5",
"linktree-parser": "^1.5.0",
Expand Down Expand Up @@ -86,8 +88,6 @@
"vite-plugin-wasm": "^3.3.0",
"vitest": "^2.1.6",
"ws": "^8.18.0",
"@atproto/api": "^0.13.18",
"fast-xml-parser": "^4.5.0",
"zod": "^3.23.8"
},
"dependencies": {
Expand Down
18 changes: 16 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export const reroute: Reroute = ({ url }) => {
// Check for cases where we route the URL without modification
if (
// When the host is the default public domain
url.host == env.PUBLIC_DOMAIN ||
// When request is a DNS challenge
url.pathname.startsWith('/__internal__/dns-challenge')
url.host == env.PUBLIC_DOMAIN
) {
return url.pathname;
}
Expand Down
Empty file removed src/lib/backend.ts
Empty file.
14 changes: 0 additions & 14 deletions src/lib/dns-challenge.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/routes/(app)/[username]/[slug]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CommonMark, Name } from 'leaf-proto/components';
import { Page } from '../types';
import { getSession } from '$lib/rauthy/server';
import { dateToUnixTimestamp } from '$lib/utils/time';
import { userRauthyIdByUsername, userSubspaceByUsername } from '$lib/usernames/index';
import { usernames } from '$lib/usernames/index';

export const load: PageServerLoad = async ({ params }): Promise<{ page: Page }> => {
const username = params.username.split('.' + env.PUBLIC_USER_DOMAIN_PARENT)[0];
Expand All @@ -18,7 +18,7 @@ export const load: PageServerLoad = async ({ params }): Promise<{ page: Page }>
? params.username!
: `${params.username}.${env.PUBLIC_USER_DOMAIN_PARENT}`;

const subspace = await userSubspaceByUsername(fullUsername);
const subspace = await usernames.getSubspace(fullUsername);
if (!subspace) return error(404, `User not found: ${fullUsername}`);
const pageLink = subspace_link(subspace, params.slug);

Expand Down Expand Up @@ -51,7 +51,7 @@ export const actions = {
const fullUsername = params.username!.includes('.')
? params.username!
: `${params.username}.${env.PUBLIC_USER_DOMAIN_PARENT}`;
const subspace = await userSubspaceByUsername(fullUsername);
const subspace = await usernames.getSubspace(fullUsername);
if (!subspace) return error(404, `User not found: ${fullUsername}`);

const oldPageLink = subspace_link(subspace, params.slug);
Expand All @@ -62,7 +62,7 @@ export const actions = {
const { sessionInfo } = await getSession(fetch, request);
if (!sessionInfo) return redirect(302, `/login?to=${url}`);

const editorIsOwner = sessionInfo.user_id == (await userRauthyIdByUsername(fullUsername));
const editorIsOwner = sessionInfo.user_id == (await usernames.getRauthyId(fullUsername));

// If this isn't a wiki page, we need to make sure that only the author can edit the page.
if (!isWikiPage && !editorIsOwner) {
Expand Down
6 changes: 1 addition & 5 deletions src/routes/(app)/[username]/new/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { error, fail, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
import { getSession } from '$lib/rauthy/server';
import { ensureUsernameMatchesSessionUserId } from '../utils';
import {
WebLinks,
WeirdWikiPage,
getProfileById,
} from '$lib/leaf/profile';
import { WebLinks, WeirdWikiPage, getProfileById } from '$lib/leaf/profile';
import { Page } from '../types';
import { leafClient, subspace_link } from '$lib/leaf';
import { CommonMark, Name } from 'leaf-proto/components';
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2a48968

Please sign in to comment.