forked from OpenWF/SpaceNinjaServer
		
	Reviewed-on: OpenWF/SpaceNinjaServer#2693 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
		
			
				
	
	
		
			21 lines
		
	
	
		
			861 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			861 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { GuildAd } from "@/src/models/guildModel";
 | 
						|
import { getGuildForRequestEx, hasGuildPermission } from "@/src/services/guildService";
 | 
						|
import { getInventory } from "@/src/services/inventoryService";
 | 
						|
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
						|
import { GuildPermission } from "@/src/types/guildTypes";
 | 
						|
import type { RequestHandler } from "express";
 | 
						|
 | 
						|
export const cancelGuildAdvertisementController: RequestHandler = async (req, res) => {
 | 
						|
    const accountId = await getAccountIdForRequest(req);
 | 
						|
    const inventory = await getInventory(accountId, "GuildId");
 | 
						|
    const guild = await getGuildForRequestEx(req, inventory);
 | 
						|
    if (!(await hasGuildPermission(guild, accountId, GuildPermission.Advertiser))) {
 | 
						|
        res.status(400).end();
 | 
						|
        return;
 | 
						|
    }
 | 
						|
 | 
						|
    await GuildAd.deleteOne({ GuildId: guild._id });
 | 
						|
 | 
						|
    res.end();
 | 
						|
};
 |