feat: clan motd #1134
@ -26,6 +26,8 @@ const getGuildController: RequestHandler = async (req, res) => {
 | 
			
		||||
            res.json({
 | 
			
		||||
                _id: toOid(guild._id),
 | 
			
		||||
                Name: guild.Name,
 | 
			
		||||
                MOTD: guild.MOTD,
 | 
			
		||||
                LongMOTD: guild.LongMOTD,
 | 
			
		||||
                Members: [
 | 
			
		||||
                    {
 | 
			
		||||
                        _id: { $oid: req.query.accountId },
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										30
									
								
								src/controllers/api/setGuildMotdController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/controllers/api/setGuildMotdController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
import { Guild } from "@/src/models/guildModel";
 | 
			
		||||
import { getInventory } from "@/src/services/inventoryService";
 | 
			
		||||
import { getAccountForRequest, getSuffixedName } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const setGuildMotdController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(account._id.toString());
 | 
			
		||||
    const guild = (await Guild.findOne({ _id: inventory.GuildId! }))!;
 | 
			
		||||
    // TODO: Check permissions
 | 
			
		||||
 | 
			
		||||
    const IsLongMOTD = "longMOTD" in req.query;
 | 
			
		||||
    const MOTD = req.body ? String(req.body) : undefined;
 | 
			
		||||
 | 
			
		||||
    if (IsLongMOTD) {
 | 
			
		||||
        if (MOTD) {
 | 
			
		||||
            guild.LongMOTD = {
 | 
			
		||||
                message: MOTD,
 | 
			
		||||
                authorName: getSuffixedName(account)
 | 
			
		||||
            };
 | 
			
		||||
        } else {
 | 
			
		||||
            guild.LongMOTD = undefined;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        guild.MOTD = MOTD ?? "";
 | 
			
		||||
    }
 | 
			
		||||
    await guild.save();
 | 
			
		||||
 | 
			
		||||
    res.json({ IsLongMOTD, MOTD });
 | 
			
		||||
};
 | 
			
		||||
@ -3,7 +3,8 @@ import {
 | 
			
		||||
    IDojoComponentDatabase,
 | 
			
		||||
    ITechProjectDatabase,
 | 
			
		||||
    ITechProjectClient,
 | 
			
		||||
    IDojoDecoDatabase
 | 
			
		||||
    IDojoDecoDatabase,
 | 
			
		||||
    ILongMOTD
 | 
			
		||||
} from "@/src/types/guildTypes";
 | 
			
		||||
import { Document, Model, model, Schema, Types } from "mongoose";
 | 
			
		||||
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
 | 
			
		||||
@ -59,9 +60,19 @@ techProjectSchema.set("toJSON", {
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const longMOTDSchema = new Schema<ILongMOTD>(
 | 
			
		||||
    {
 | 
			
		||||
        message: String,
 | 
			
		||||
        authorName: String
 | 
			
		||||
    },
 | 
			
		||||
    { _id: false }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
const guildSchema = new Schema<IGuildDatabase>(
 | 
			
		||||
    {
 | 
			
		||||
        Name: { type: String, required: true },
 | 
			
		||||
        MOTD: { type: String, default: "" },
 | 
			
		||||
        LongMOTD: { type: longMOTDSchema, default: undefined },
 | 
			
		||||
        DojoComponents: { type: [dojoComponentSchema], default: [] },
 | 
			
		||||
        DojoCapacity: { type: Number, default: 100 },
 | 
			
		||||
        DojoEnergy: { type: Number, default: 5 },
 | 
			
		||||
 | 
			
		||||
@ -79,6 +79,7 @@ import { setActiveShipController } from "@/src/controllers/api/setActiveShipCont
 | 
			
		||||
import { setBootLocationController } from "@/src/controllers/api/setBootLocationController";
 | 
			
		||||
import { setDojoComponentMessageController } from "@/src/controllers/api/setDojoComponentMessageController";
 | 
			
		||||
import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
 | 
			
		||||
import { setGuildMotdController } from "@/src/controllers/api/setGuildMotdController";
 | 
			
		||||
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
 | 
			
		||||
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
 | 
			
		||||
import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
 | 
			
		||||
@ -138,6 +139,7 @@ apiRouter.get("/queueDojoComponentDestruction.php", queueDojoComponentDestructio
 | 
			
		||||
apiRouter.get("/setActiveQuest.php", setActiveQuestController);
 | 
			
		||||
apiRouter.get("/setActiveShip.php", setActiveShipController);
 | 
			
		||||
apiRouter.get("/setBootLocation.php", setBootLocationController);
 | 
			
		||||
apiRouter.get("/setGuildMotd.php", setGuildMotdController);
 | 
			
		||||
apiRouter.get("/setSupportedSyndicate.php", setSupportedSyndicateController);
 | 
			
		||||
apiRouter.get("/startLibraryDailyTask.php", startLibraryDailyTaskController);
 | 
			
		||||
apiRouter.get("/startLibraryPersonalTarget.php", startLibraryPersonalTargetController);
 | 
			
		||||
@ -197,6 +199,7 @@ apiRouter.post("/saveSettings.php", saveSettingsController);
 | 
			
		||||
apiRouter.post("/sell.php", sellController);
 | 
			
		||||
apiRouter.post("/setDojoComponentMessage.php", setDojoComponentMessageController);
 | 
			
		||||
apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
 | 
			
		||||
apiRouter.post("/setGuildMotd.php", setGuildMotdController);
 | 
			
		||||
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
 | 
			
		||||
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
 | 
			
		||||
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,8 @@ import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTyp
 | 
			
		||||
export interface IGuildDatabase {
 | 
			
		||||
    _id: Types.ObjectId;
 | 
			
		||||
    Name: string;
 | 
			
		||||
    MOTD: string;
 | 
			
		||||
    LongMOTD?: ILongMOTD;
 | 
			
		||||
 | 
			
		||||
    DojoComponents: IDojoComponentDatabase[];
 | 
			
		||||
    DojoCapacity: number;
 | 
			
		||||
@ -27,6 +29,12 @@ export interface IGuildDatabase {
 | 
			
		||||
    CeremonyResetDate?: Date;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface ILongMOTD {
 | 
			
		||||
    message: string;
 | 
			
		||||
    authorName: string;
 | 
			
		||||
    //authorGuildName: "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IGuildVault {
 | 
			
		||||
    DojoRefundRegularCredits?: number;
 | 
			
		||||
    DojoRefundMiscItems?: IMiscItem[];
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user