feat: clan motd
All checks were successful
Build / build (20) (push) Successful in 40s
Build / build (22) (push) Successful in 1m1s
Build / build (18) (push) Successful in 58s
Build / build (20) (pull_request) Successful in 1m2s
Build / build (18) (pull_request) Successful in 40s
Build / build (22) (pull_request) Successful in 57s
All checks were successful
Build / build (20) (push) Successful in 40s
Build / build (22) (push) Successful in 1m1s
Build / build (18) (push) Successful in 58s
Build / build (20) (pull_request) Successful in 1m2s
Build / build (18) (pull_request) Successful in 40s
Build / build (22) (pull_request) Successful in 57s
This commit is contained in:
parent
2f24b61825
commit
3a8ff8ca2e
@ -26,6 +26,8 @@ const getGuildController: RequestHandler = async (req, res) => {
|
|||||||
res.json({
|
res.json({
|
||||||
_id: toOid(guild._id),
|
_id: toOid(guild._id),
|
||||||
Name: guild.Name,
|
Name: guild.Name,
|
||||||
|
MOTD: guild.MOTD,
|
||||||
|
LongMOTD: guild.LongMOTD,
|
||||||
Members: [
|
Members: [
|
||||||
{
|
{
|
||||||
_id: { $oid: req.query.accountId },
|
_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,
|
IDojoComponentDatabase,
|
||||||
ITechProjectDatabase,
|
ITechProjectDatabase,
|
||||||
ITechProjectClient,
|
ITechProjectClient,
|
||||||
IDojoDecoDatabase
|
IDojoDecoDatabase,
|
||||||
|
ILongMOTD
|
||||||
} from "@/src/types/guildTypes";
|
} from "@/src/types/guildTypes";
|
||||||
import { Document, Model, model, Schema, Types } from "mongoose";
|
import { Document, Model, model, Schema, Types } from "mongoose";
|
||||||
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
|
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>(
|
const guildSchema = new Schema<IGuildDatabase>(
|
||||||
{
|
{
|
||||||
Name: { type: String, required: true },
|
Name: { type: String, required: true },
|
||||||
|
MOTD: { type: String, default: "" },
|
||||||
|
LongMOTD: { type: longMOTDSchema, default: undefined },
|
||||||
DojoComponents: { type: [dojoComponentSchema], default: [] },
|
DojoComponents: { type: [dojoComponentSchema], default: [] },
|
||||||
DojoCapacity: { type: Number, default: 100 },
|
DojoCapacity: { type: Number, default: 100 },
|
||||||
DojoEnergy: { type: Number, default: 5 },
|
DojoEnergy: { type: Number, default: 5 },
|
||||||
|
@ -79,6 +79,7 @@ import { setActiveShipController } from "@/src/controllers/api/setActiveShipCont
|
|||||||
import { setBootLocationController } from "@/src/controllers/api/setBootLocationController";
|
import { setBootLocationController } from "@/src/controllers/api/setBootLocationController";
|
||||||
import { setDojoComponentMessageController } from "@/src/controllers/api/setDojoComponentMessageController";
|
import { setDojoComponentMessageController } from "@/src/controllers/api/setDojoComponentMessageController";
|
||||||
import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
|
import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
|
||||||
|
import { setGuildMotdController } from "@/src/controllers/api/setGuildMotdController";
|
||||||
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
|
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
|
||||||
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
|
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
|
||||||
import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
|
import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
|
||||||
@ -138,6 +139,7 @@ apiRouter.get("/queueDojoComponentDestruction.php", queueDojoComponentDestructio
|
|||||||
apiRouter.get("/setActiveQuest.php", setActiveQuestController);
|
apiRouter.get("/setActiveQuest.php", setActiveQuestController);
|
||||||
apiRouter.get("/setActiveShip.php", setActiveShipController);
|
apiRouter.get("/setActiveShip.php", setActiveShipController);
|
||||||
apiRouter.get("/setBootLocation.php", setBootLocationController);
|
apiRouter.get("/setBootLocation.php", setBootLocationController);
|
||||||
|
apiRouter.get("/setGuildMotd.php", setGuildMotdController);
|
||||||
apiRouter.get("/setSupportedSyndicate.php", setSupportedSyndicateController);
|
apiRouter.get("/setSupportedSyndicate.php", setSupportedSyndicateController);
|
||||||
apiRouter.get("/startLibraryDailyTask.php", startLibraryDailyTaskController);
|
apiRouter.get("/startLibraryDailyTask.php", startLibraryDailyTaskController);
|
||||||
apiRouter.get("/startLibraryPersonalTarget.php", startLibraryPersonalTargetController);
|
apiRouter.get("/startLibraryPersonalTarget.php", startLibraryPersonalTargetController);
|
||||||
@ -197,6 +199,7 @@ apiRouter.post("/saveSettings.php", saveSettingsController);
|
|||||||
apiRouter.post("/sell.php", sellController);
|
apiRouter.post("/sell.php", sellController);
|
||||||
apiRouter.post("/setDojoComponentMessage.php", setDojoComponentMessageController);
|
apiRouter.post("/setDojoComponentMessage.php", setDojoComponentMessageController);
|
||||||
apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
|
apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
|
||||||
|
apiRouter.post("/setGuildMotd.php", setGuildMotdController);
|
||||||
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
|
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
|
||||||
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
|
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
|
||||||
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
|
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
|
||||||
|
@ -5,6 +5,8 @@ import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTyp
|
|||||||
export interface IGuildDatabase {
|
export interface IGuildDatabase {
|
||||||
_id: Types.ObjectId;
|
_id: Types.ObjectId;
|
||||||
Name: string;
|
Name: string;
|
||||||
|
MOTD: string;
|
||||||
|
LongMOTD?: ILongMOTD;
|
||||||
|
|
||||||
DojoComponents: IDojoComponentDatabase[];
|
DojoComponents: IDojoComponentDatabase[];
|
||||||
DojoCapacity: number;
|
DojoCapacity: number;
|
||||||
@ -27,6 +29,12 @@ export interface IGuildDatabase {
|
|||||||
CeremonyResetDate?: Date;
|
CeremonyResetDate?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ILongMOTD {
|
||||||
|
message: string;
|
||||||
|
authorName: string;
|
||||||
|
//authorGuildName: "";
|
||||||
|
}
|
||||||
|
|
||||||
export interface IGuildVault {
|
export interface IGuildVault {
|
||||||
DojoRefundRegularCredits?: number;
|
DojoRefundRegularCredits?: number;
|
||||||
DojoRefundMiscItems?: IMiscItem[];
|
DojoRefundMiscItems?: IMiscItem[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user