feat: implement startDojoRecipeController to place new rooms in Dojo #273

Merged
Sainan merged 6 commits from dojo-ii into main 2024-06-06 07:55:37 -07:00
2 changed files with 21 additions and 16 deletions
Showing only changes of commit 41f27362d2 - Show all commits

View File

@ -1,8 +1,6 @@
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { IDojoComponentClient } from "@/src/types/guildTypes"; import { IDojoComponentClient } from "@/src/types/guildTypes";
import { getAccountIdForRequest } from "@/src/services/loginService"; import { getGuildForRequest } from "@/src/services/guildService";
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
import { Guild } from "@/src/models/guildModel";
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
import { Types } from "mongoose"; import { Types } from "mongoose";
interface IStartDojoRecipeRequest { interface IStartDojoRecipeRequest {
@ -11,19 +9,8 @@ interface IStartDojoRecipeRequest {
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
} }
export const startDojoRecipeController: RequestHandler = async (req, res) => { export const startDojoRecipeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const guild = await getGuildForRequest(req);
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
const inventory = await Inventory.findOne({ accountOwnerId: accountId }); // At this point, we know that a member of the guild is making this request. Assuming they are allowed to start a build.
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
if (!inventory) {
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
res.status(400).end();
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
return;
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
}
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
const guildId = req.query.guildId as string;
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
res.status(400).end();
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
return;
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
}
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
// Verified that a member of the guild is making this request. Assuming they are allowed to start a build.
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
const guild = (await Guild.findOne({ _id: guildId }))!;
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
const request = JSON.parse(req.body.toString()) as IStartDojoRecipeRequest; const request = JSON.parse(req.body.toString()) as IStartDojoRecipeRequest;
guild.DojoComponents!.push({ guild.DojoComponents!.push({
_id: new Types.ObjectId(), _id: new Types.ObjectId(),

OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:27:58 -07:00 (Migrated from github.com)
Review

could use getInventory()

could use getInventory()
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:29:34 -07:00 (Migrated from github.com)
Review

perhaps this could be a getGuild() function, seems like we would need that often

perhaps this could be a getGuild() function, seems like we would need that often
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed
OrdisPrime commented 2024-06-06 05:30:11 -07:00 (Migrated from github.com)
Review

i dont like the non-null assertion operator here.
I would prefer coding it such that it is checked before null before, so this is not needed

i dont like the non-null assertion operator here. I would prefer coding it such that it is checked before null before, so this is not needed

View File

@ -0,0 +1,18 @@
import { Request } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
import { Guild } from "@/src/models/guildModel";
export const getGuildForRequest = async (req: Request) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const guildId = req.query.guildId as string;
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
throw new Error("Account is not in the guild that it has sent a request for");
}
const guild = await Guild.findOne({ _id: guildId });
if (!guild) {
throw new Error("Account thinks it is a in guild that doesn't exist");
}
return guild;
};