add TGuildDatabaseDocument
This commit is contained in:
		
							parent
							
								
									8b76eaffe8
								
							
						
					
					
						commit
						e1e363b340
					
				@ -3,14 +3,19 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
			
		||||
import { IGuildDatabase } from "@/src/types/guildTypes";
 | 
			
		||||
import { Document, Types } from "mongoose";
 | 
			
		||||
 | 
			
		||||
export const getGuildForRequest = async (req: Request) => {
 | 
			
		||||
export const getGuildForRequest = async (req: Request): Promise<TGuildDatabaseDocument> => {
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    return await getGuildForRequestEx(req, inventory);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getGuildForRequestEx = async (req: Request, inventory: TInventoryDatabaseDocument) => {
 | 
			
		||||
export const getGuildForRequestEx = async (
 | 
			
		||||
    req: Request,
 | 
			
		||||
    inventory: TInventoryDatabaseDocument
 | 
			
		||||
): Promise<TGuildDatabaseDocument> => {
 | 
			
		||||
    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");
 | 
			
		||||
@ -21,3 +26,12 @@ export const getGuildForRequestEx = async (req: Request, inventory: TInventoryDa
 | 
			
		||||
    }
 | 
			
		||||
    return guild;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/ban-types
 | 
			
		||||
type TGuildDatabaseDocument = Document<unknown, {}, IGuildDatabase> &
 | 
			
		||||
    IGuildDatabase &
 | 
			
		||||
    Required<{
 | 
			
		||||
        _id: Types.ObjectId;
 | 
			
		||||
    }> & {
 | 
			
		||||
        __v: number;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user