Skip to content

Commit

Permalink
Merge pull request #363 from Yooooomi/hotfix/import-missing-tokens
Browse files Browse the repository at this point in the history
fixed import missing user tokens
  • Loading branch information
Yooooomi committed Mar 8, 2024
2 parents bba31e0 + b10c95c commit ef46ab5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions apps/server/src/routes/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ router.post(
runImporter(
null,
ImporterStateTypes.privacy,
user,
user._id.toString(),
(files as Express.Multer.File[]).map(f => f.path),
success => {
if (success) {
Expand Down Expand Up @@ -87,7 +87,7 @@ router.post(
runImporter(
null,
ImporterStateTypes.fullPrivacy,
user,
user._id.toString(),
(files as Express.Multer.File[]).map(f => f.path),
success => {
if (success) {
Expand Down Expand Up @@ -134,7 +134,7 @@ router.post(
runImporter(
importState._id.toString(),
importState.type,
user,
user._id.toString(),
importState.metadata,
success => {
if (success) {
Expand Down
9 changes: 7 additions & 2 deletions apps/server/src/tools/importers/importer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Types } from "mongoose";
import { getUserFromField } from "../../database";
import {
createImporterState,
Expand Down Expand Up @@ -58,11 +59,15 @@ export async function cleanupImport(existingStateId: string) {
export async function runImporter<T extends ImporterStateTypes>(
existingStateId: string | null,
name: T,
user: User,
userId: string,
requiredInitData: ImporterStateFromType<T>["metadata"],
initDone: (success: boolean) => void,
) {
const userId = user._id.toString();
const user = await getUserFromField("_id", new Types.ObjectId(userId), true);
if (!user) {
logger.error(`User with id ${userId} was not found`);
return initDone(false);
}
const importerClass = importers[name];
if (!importerClass) {
logger.error(`${name} importer was not found`);
Expand Down

0 comments on commit ef46ab5

Please sign in to comment.