diff --git a/src/controllers/api/createGuildController.ts b/src/controllers/api/createGuildController.ts index badaa467..88cace67 100644 --- a/src/controllers/api/createGuildController.ts +++ b/src/controllers/api/createGuildController.ts @@ -2,7 +2,7 @@ import { RequestHandler } from "express"; import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Guild } from "@/src/models/guildModel"; -import { IGuild, ICreateGuildRequest } from "@/src/types/guildTypes"; +import { ICreateGuildRequest } from "@/src/types/guildTypes"; const createGuildController: RequestHandler = async (req, res) => { const payload: ICreateGuildRequest = getJSONfromString(req.body.toString()); @@ -10,7 +10,7 @@ const createGuildController: RequestHandler = async (req, res) => { // Create guild on database const guild = new Guild({ Name: payload.guildName - } satisfies IGuild); + }); await guild.save(); // Update inventory diff --git a/src/controllers/api/getGuildController.ts b/src/controllers/api/getGuildController.ts index 81dfde24..a91bf5dd 100644 --- a/src/controllers/api/getGuildController.ts +++ b/src/controllers/api/getGuildController.ts @@ -1,6 +1,7 @@ import { RequestHandler } from "express"; import { Inventory } from "@/src/models/inventoryModels/inventoryModel"; import { Guild } from "@/src/models/guildModel"; +import { toOid } from "@/src/helpers/inventoryHelpers"; const getGuildController: RequestHandler = async (req, res) => { if (!req.query.accountId) { @@ -15,7 +16,56 @@ const getGuildController: RequestHandler = async (req, res) => { if (inventory.GuildId) { const guild = await Guild.findOne({ _id: inventory.GuildId }); if (guild) { - res.json(guild); + res.json({ + _id: toOid(guild._id), + Name: guild.Name, + Members: [ + { + _id: { $oid: req.query.accountId }, + Rank: 0, + Status: 0 + } + ], + Ranks: [ + { + Name: "/Lotus/Language/Game/Rank_Creator", + Permissions: 16351 + }, + { + Name: "/Lotus/Language/Game/Rank_Warlord", + Permissions: 14303 + }, + { + Name: "/Lotus/Language/Game/Rank_General", + Permissions: 4318 + }, + { + Name: "/Lotus/Language/Game/Rank_Officer", + Permissions: 4314 + }, + { + Name: "/Lotus/Language/Game/Rank_Leader", + Permissions: 4106 + }, + { + Name: "/Lotus/Language/Game/Rank_Sage", + Permissions: 4304 + }, + { + Name: "/Lotus/Language/Game/Rank_Soldier", + Permissions: 4098 + }, + { + Name: "/Lotus/Language/Game/Rank_Initiate", + Permissions: 4096 + }, + { + Name: "/Lotus/Language/Game/Rank_Utility", + Permissions: 4096 + } + ], + Tier: 1 + }); return; } } diff --git a/src/models/guildModel.ts b/src/models/guildModel.ts index 450bf06c..157007a0 100644 --- a/src/models/guildModel.ts +++ b/src/models/guildModel.ts @@ -1,6 +1,5 @@ import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes"; import { model, Schema } from "mongoose"; -import { toOid } from "@/src/helpers/inventoryHelpers"; const dojoComponentSchema = new Schema({ pf: { type: String, required: true }, @@ -16,12 +15,4 @@ const guildSchema = new Schema( { id: false } ); -guildSchema.set("toJSON", { - virtuals: true, - transform(_document, guild) { - guild._id = toOid(guild._id); - delete guild.__v; - } -}); - export const Guild = model("Guild", guildSchema);