mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +00:00
big overhaul (#474)
* miniflare init * feat(api): add tests * chore: more tests, almost 100% * add sessions/state spec * add majority of routes and datapaths, start on interactions * nevermind, no interactions * nevermind x2, tweetnacl is bad but SubtleCrypto has what we need apparently * simplify interactions verify * add brute force interactions tests * every primary path API route is refactored! * automatically import from legacy, or die trying. * check that we only fetch legacy once, ever * remove old-src, same some historic pieces * remove interactions & worker-utils package, update misc/types * update some packages we don't need specific pinning for anymore * update web references to API routes since they all changed * fix all linting issues, upgrade most packages * fix tests, divorce enzyme where-ever possible * update web, fix integration issues * pre-build api * fix tests * move api pretest to api package.json instead of CI * remove interactions from terraform, fix deploy side configs * update to tf 1.1.4 * prevent double writes to worker in GCS, port to newer GCP auth workflow * fix api.tf var refs, upgrade node action * change to curl-based script upload for worker script due to terraform provider limitations * oh no, cloudflare freaked out :(
This commit is contained in:
parent
b644a38aa7
commit
3291f9aacc
183 changed files with 9853 additions and 9924 deletions
|
@ -15,13 +15,13 @@ const Login = (props: { path: string }) => {
|
|||
// If ?r is in query, then let's render the slug page
|
||||
// If not, redirect.
|
||||
const [guildSlug, setGuildSlug] = React.useState<GuildSlug | null>(null);
|
||||
const [oauthLink, setOauthLink] = React.useState(`${apiUrl}/login-bounce`);
|
||||
const [oauthLink, setOauthLink] = React.useState(`${apiUrl}/auth/bounce`);
|
||||
|
||||
React.useEffect(() => {
|
||||
const url = new URL(window.location.href);
|
||||
const callbackHost = new URL('/', url);
|
||||
const redirectServerID = url.searchParams.get('r');
|
||||
const redirectUrl = `${apiUrl}/login-bounce?cbh=${callbackHost.href}`;
|
||||
const redirectUrl = `${apiUrl}/auth/bounce?cbh=${callbackHost.href}`;
|
||||
if (!redirectServerID) {
|
||||
if (isAuthenticated) {
|
||||
redirectTo('/servers');
|
||||
|
|
|
@ -10,6 +10,7 @@ import * as React from 'react';
|
|||
import { useAppShellProps } from '../contexts/app-shell/AppShellContext';
|
||||
import { useGuildContext } from '../contexts/guild/GuildContext';
|
||||
import { useRecentGuilds } from '../contexts/recent-guilds/RecentGuildsContext';
|
||||
import { useAuthedFetch } from '../contexts/session/AuthedFetchContext';
|
||||
import { useSessionContext } from '../contexts/session/SessionContext';
|
||||
import { Title } from '../utils/metaTitle';
|
||||
|
||||
|
@ -20,10 +21,11 @@ type EditorProps = {
|
|||
|
||||
const Editor = (props: EditorProps) => {
|
||||
const { serverID } = props;
|
||||
const { session, authedFetch, isAuthenticated } = useSessionContext();
|
||||
const { session, isAuthenticated } = useSessionContext();
|
||||
const { authedFetch } = useAuthedFetch();
|
||||
const { pushRecentGuild } = useRecentGuilds();
|
||||
const appShellProps = useAppShellProps();
|
||||
const { getFullGuild } = useGuildContext();
|
||||
const { getFullGuild, uncacheGuild } = useGuildContext();
|
||||
|
||||
const [guild, setGuild] = React.useState<PresentableGuild | null | false>(null);
|
||||
const [pending, setPending] = React.useState(false);
|
||||
|
@ -89,13 +91,14 @@ const Editor = (props: EditorProps) => {
|
|||
categories: guild.data.categories,
|
||||
};
|
||||
|
||||
const response = await authedFetch(`/update-guild/${serverID}`, {
|
||||
const response = await authedFetch(`/guilds/${serverID}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(updatePayload),
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
setGuild(guild);
|
||||
uncacheGuild(serverID);
|
||||
navigate(`/s/${props.serverID}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,12 @@ import React from 'react';
|
|||
import { useAppShellProps } from '../../contexts/app-shell/AppShellContext';
|
||||
import { useGuildContext } from '../../contexts/guild/GuildContext';
|
||||
import { useRecentGuilds } from '../../contexts/recent-guilds/RecentGuildsContext';
|
||||
import { useAuthedFetch } from '../../contexts/session/AuthedFetchContext';
|
||||
import { useSessionContext } from '../../contexts/session/SessionContext';
|
||||
|
||||
const AccessControlPage = (props: { serverID: string; path: string }) => {
|
||||
const { session, isAuthenticated, authedFetch } = useSessionContext();
|
||||
const { session, isAuthenticated } = useSessionContext();
|
||||
const { authedFetch } = useAuthedFetch();
|
||||
const { pushRecentGuild } = useRecentGuilds();
|
||||
const { getFullGuild, uncacheGuild } = useGuildContext();
|
||||
const appShellProps = useAppShellProps();
|
||||
|
|
|
@ -10,7 +10,7 @@ const BotJoin = (props: { serverID: string; path: string }) => {
|
|||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
window.location.href = `${apiUrl}/bot-join${params}`;
|
||||
window.location.href = `${apiUrl}/auth/bot${params}`;
|
||||
}, [apiUrl, params]);
|
||||
|
||||
return <GenericLoadingTemplate />;
|
||||
|
|
|
@ -7,6 +7,7 @@ import * as React from 'react';
|
|||
import { useAppShellProps } from '../contexts/app-shell/AppShellContext';
|
||||
import { useGuildContext } from '../contexts/guild/GuildContext';
|
||||
import { useRecentGuilds } from '../contexts/recent-guilds/RecentGuildsContext';
|
||||
import { useAuthedFetch } from '../contexts/session/AuthedFetchContext';
|
||||
import { useSessionContext } from '../contexts/session/SessionContext';
|
||||
import { Title } from '../utils/metaTitle';
|
||||
import { makeRoleTransactions } from '../utils/roleTransactions';
|
||||
|
@ -17,7 +18,8 @@ type PickerProps = {
|
|||
};
|
||||
|
||||
const Picker = (props: PickerProps) => {
|
||||
const { session, authedFetch, isAuthenticated } = useSessionContext();
|
||||
const { session, isAuthenticated } = useSessionContext();
|
||||
const { authedFetch } = useAuthedFetch();
|
||||
const { pushRecentGuild } = useRecentGuilds();
|
||||
const appShellProps = useAppShellProps();
|
||||
const { getFullGuild, uncacheGuild } = useGuildContext();
|
||||
|
@ -65,7 +67,7 @@ const Picker = (props: PickerProps) => {
|
|||
const guildSlug = session.guilds.find((guild) => guild.id === props.serverID);
|
||||
|
||||
if (!guildSlug) {
|
||||
console.error({ error: 'guold not in session, 404' });
|
||||
console.error({ error: 'guild not in session, 404' });
|
||||
return <Redirect to="/error/404" replace />;
|
||||
}
|
||||
|
||||
|
@ -94,8 +96,8 @@ const Picker = (props: PickerProps) => {
|
|||
};
|
||||
|
||||
uncacheGuild(props.serverID);
|
||||
const response = await authedFetch(`/update-roles/${props.serverID}`, {
|
||||
method: 'PATCH',
|
||||
const response = await authedFetch(`/guilds/${props.serverID}/roles`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(updatePayload),
|
||||
});
|
||||
if (response.status === 200) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue