chore: sync from legacy redo

This commit is contained in:
41666 2021-08-01 13:17:34 -04:00
parent dde05c402e
commit c4dda617b1
7 changed files with 67 additions and 2 deletions

View file

@ -0,0 +1,18 @@
import { respond } from '@roleypoly/api/utils/api-tools';
import { asEditor } from '@roleypoly/api/utils/guild';
import {
fetchLegacyServer,
transformLegacyGuild,
} from '@roleypoly/api/utils/import-from-legacy';
import { notFound } from '@roleypoly/api/utils/responses';
export const FetchFromLegacy = asEditor({}, (session, { guildID }) => async () => {
const legacyGuild = await fetchLegacyServer(guildID);
if (!legacyGuild) {
return notFound();
}
const transformedGuild = transformLegacyGuild(legacyGuild);
return respond(transformedGuild);
});

View file

@ -1,5 +1,6 @@
import { BotJoin } from './handlers/bot-join';
import { ClearGuildCache } from './handlers/clear-guild-cache';
import { FetchFromLegacy } from './handlers/fetch-from-legacy';
import { GetPickerData } from './handlers/get-picker-data';
import { GetSession } from './handlers/get-session';
import { GetSlug } from './handlers/get-slug';
@ -29,9 +30,12 @@ router.add('GET', 'get-slug', GetSlug);
router.add('GET', 'get-picker-data', GetPickerData);
router.add('PATCH', 'update-roles', UpdateRoles);
router.add('PATCH', 'update-guild', UpdateGuild);
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
router.add('POST', 'clear-guild-cache', ClearGuildCache);
// Legacy sync stuff
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
router.add('GET', 'fetch-from-legacy', FetchFromLegacy);
// Tester Routes
router.add('GET', 'x-headers', (request) => {
const headers: { [x: string]: string } = {};

View file

@ -168,7 +168,9 @@ export const getGuildData = async (id: string): Promise<GuildDataT> => {
};
if (!guildData) {
return empty;
return {
...empty,
};
}
return {