forked from OpenWF/SpaceNinjaServer
		
	chore: faithful response to getGuild & getGuildLog when not in a clan (#1159)
Reviewed-on: OpenWF/SpaceNinjaServer#1159
This commit is contained in:
		
							parent
							
								
									8daf0c9eda
								
							
						
					
					
						commit
						02ce0f57a6
					
				@ -28,7 +28,7 @@ const getGuildController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    res.json({});
 | 
					    res.sendStatus(200);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { getGuildController };
 | 
					export { getGuildController };
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,11 @@ import { IMongoDate } from "@/src/types/commonTypes";
 | 
				
			|||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getGuildLogController: RequestHandler = async (req, res) => {
 | 
					export const getGuildLogController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					    if (inventory.GuildId) {
 | 
				
			||||||
 | 
					        const guild = await Guild.findOne({ _id: inventory.GuildId });
 | 
				
			||||||
 | 
					        if (guild) {
 | 
				
			||||||
            const log: Record<string, IGuildLogEntryClient[]> = {
 | 
					            const log: Record<string, IGuildLogEntryClient[]> = {
 | 
				
			||||||
                RoomChanges: [],
 | 
					                RoomChanges: [],
 | 
				
			||||||
                TechChanges: [],
 | 
					                TechChanges: [],
 | 
				
			||||||
@ -13,11 +18,6 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                StandingsUpdates: [],
 | 
					                StandingsUpdates: [],
 | 
				
			||||||
                ClassChanges: []
 | 
					                ClassChanges: []
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					 | 
				
			||||||
    if (inventory.GuildId) {
 | 
					 | 
				
			||||||
        const guild = await Guild.findOne({ _id: inventory.GuildId });
 | 
					 | 
				
			||||||
        if (guild) {
 | 
					 | 
				
			||||||
            guild.ClassChanges?.forEach(entry => {
 | 
					            guild.ClassChanges?.forEach(entry => {
 | 
				
			||||||
                log.ClassChanges.push({
 | 
					                log.ClassChanges.push({
 | 
				
			||||||
                    dateTime: toMongoDate(entry.dateTime),
 | 
					                    dateTime: toMongoDate(entry.dateTime),
 | 
				
			||||||
@ -25,9 +25,11 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                    details: entry.details
 | 
					                    details: entry.details
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
            res.json(log);
 | 
					            res.json(log);
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    res.sendStatus(200);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IGuildLogEntryClient {
 | 
					interface IGuildLogEntryClient {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user