chore: some fixes to enter guild dojo on U15 #2088
@ -62,7 +62,7 @@ export const confirmGuildInvitationGetController: RequestHandler = async (req, r
|
|||||||
await guild.save();
|
await guild.save();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
...(await getGuildClient(guild, account._id.toString())),
|
...(await getGuildClient(guild, account)),
|
||||||
InventoryChanges: inventoryChanges
|
InventoryChanges: inventoryChanges
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Guild, GuildMember } from "@/src/models/guildModel";
|
import { Guild, GuildMember } from "@/src/models/guildModel";
|
||||||
import { createUniqueClanName, getGuildClient, giveClanKey } from "@/src/services/guildService";
|
import { createUniqueClanName, getGuildClient, giveClanKey } from "@/src/services/guildService";
|
||||||
@ -7,11 +7,11 @@ import { getInventory } from "@/src/services/inventoryService";
|
|||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
|
|
||||||
export const createGuildController: RequestHandler = async (req, res) => {
|
export const createGuildController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const payload = getJSONfromString<ICreateGuildRequest>(String(req.body));
|
const payload = getJSONfromString<ICreateGuildRequest>(String(req.body));
|
||||||
|
|
||||||
// Remove pending applications for this account
|
// Remove pending applications for this account
|
||||||
await GuildMember.deleteMany({ accountId, status: 1 });
|
await GuildMember.deleteMany({ accountId: account._id, status: 1 });
|
||||||
|
|
||||||
// Create guild on database
|
// Create guild on database
|
||||||
const guild = new Guild({
|
const guild = new Guild({
|
||||||
@ -21,20 +21,20 @@ export const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
|
|
||||||
// Create guild member on database
|
// Create guild member on database
|
||||||
await GuildMember.insertOne({
|
await GuildMember.insertOne({
|
||||||
accountId: accountId,
|
accountId: account._id,
|
||||||
guildId: guild._id,
|
guildId: guild._id,
|
||||||
status: 0,
|
status: 0,
|
||||||
rank: 0
|
rank: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const inventory = await getInventory(accountId, "GuildId LevelKeys Recipes");
|
const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
|
||||||
inventory.GuildId = guild._id;
|
inventory.GuildId = guild._id;
|
||||||
const inventoryChanges: IInventoryChanges = {};
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
giveClanKey(inventory, inventoryChanges);
|
giveClanKey(inventory, inventoryChanges);
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
...(await getGuildClient(guild, accountId)),
|
...(await getGuildClient(guild, account)),
|
||||||
InventoryChanges: inventoryChanges
|
InventoryChanges: inventoryChanges
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
import { createUniqueClanName, getGuildClient } from "@/src/services/guildService";
|
import { createUniqueClanName, getGuildClient } from "@/src/services/guildService";
|
||||||
|
|
||||||
export const getGuildController: RequestHandler = async (req, res) => {
|
export const getGuildController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const inventory = await getInventory(accountId, "GuildId");
|
const inventory = await getInventory(account._id.toString(), "GuildId");
|
||||||
if (inventory.GuildId) {
|
if (inventory.GuildId) {
|
||||||
const guild = await Guild.findById(inventory.GuildId);
|
const guild = await Guild.findById(inventory.GuildId);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
@ -24,7 +24,7 @@ export const getGuildController: RequestHandler = async (req, res) => {
|
|||||||
guild.CeremonyResetDate = undefined;
|
guild.CeremonyResetDate = undefined;
|
||||||
await guild.save();
|
await guild.save();
|
||||||
}
|
}
|
||||||
res.json(await getGuildClient(guild, accountId));
|
res.json(await getGuildClient(guild, account));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { RequestHandler } from "express";
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
import { getDojoClient } from "@/src/services/guildService";
|
import { getDojoClient } from "@/src/services/guildService";
|
||||||
|
import { Account } from "@/src/models/loginModel";
|
||||||
|
|
||||||
export const getGuildDojoController: RequestHandler = async (req, res) => {
|
export const getGuildDojoController: RequestHandler = async (req, res) => {
|
||||||
const guildId = req.query.guildId as string;
|
const guildId = req.query.guildId as string;
|
||||||
@ -25,7 +26,8 @@ export const getGuildDojoController: RequestHandler = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const payload: IGetGuildDojoRequest = req.body ? (JSON.parse(String(req.body)) as IGetGuildDojoRequest) : {};
|
const payload: IGetGuildDojoRequest = req.body ? (JSON.parse(String(req.body)) as IGetGuildDojoRequest) : {};
|
||||||
res.json(await getDojoClient(guild, 0, payload.ComponentId));
|
const account = await Account.findById(req.query.accountId as string);
|
||||||
|
res.json(await getDojoClient(guild, 0, payload.ComponentId, account?.BuildLabel));
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IGetGuildDojoRequest {
|
interface IGetGuildDojoRequest {
|
||||||
|
@ -1,17 +1,24 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
import { createNewSession } from "@/src/managers/sessionManager";
|
import { createNewSession } from "@/src/managers/sessionManager";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { ISession } from "@/src/types/session";
|
import { ISession } from "@/src/types/session";
|
||||||
|
import { JSONParse } from "json-with-bigint";
|
||||||
|
import { toOid2, version_compare } from "@/src/helpers/inventoryHelpers";
|
||||||
|
|
||||||
const hostSessionController: RequestHandler = async (req, res) => {
|
const hostSessionController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const hostSessionRequest = JSON.parse(req.body as string) as ISession;
|
const hostSessionRequest = JSONParse(String(req.body)) as ISession;
|
||||||
logger.debug("HostSession Request", { hostSessionRequest });
|
logger.debug("HostSession Request", { hostSessionRequest });
|
||||||
const session = createNewSession(hostSessionRequest, accountId);
|
const session = createNewSession(hostSessionRequest, account._id);
|
||||||
logger.debug(`New Session Created`, { session });
|
logger.debug(`New Session Created`, { session });
|
||||||
|
|
||||||
res.json({ sessionId: { $oid: session.sessionId }, rewardSeed: 99999999 });
|
if (account.BuildLabel && version_compare(account.BuildLabel, "2015.03.21.08.17") < 0) {
|
||||||
|
// U15 or below
|
||||||
|
res.send(session.sessionId.toString());
|
||||||
|
} else {
|
||||||
|
res.json({ sessionId: toOid2(session.sessionId, account.BuildLabel), rewardSeed: 99999999 });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { hostSessionController };
|
export { hostSessionController };
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||||
import { config } from "@/src/services/configService";
|
import { config } from "@/src/services/configService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
|
||||||
interface IStartDojoRecipeRequest {
|
interface IStartDojoRecipeRequest {
|
||||||
@ -20,10 +20,10 @@ interface IStartDojoRecipeRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const startDojoRecipeController: RequestHandler = async (req, res) => {
|
export const startDojoRecipeController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const inventory = await getInventory(accountId, "GuildId LevelKeys");
|
const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys");
|
||||||
const guild = await getGuildForRequestEx(req, inventory);
|
const guild = await getGuildForRequestEx(req, inventory);
|
||||||
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Architect))) {
|
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, account._id, GuildPermission.Architect))) {
|
||||||
res.json({ DojoRequestStatus: -1 });
|
res.json({ DojoRequestStatus: -1 });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,5 +64,5 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
|
|||||||
setDojoRoomLogFunded(guild, component);
|
setDojoRoomLogFunded(guild, component);
|
||||||
}
|
}
|
||||||
await guild.save();
|
await guild.save();
|
||||||
res.json(await getDojoClient(guild, 0));
|
res.json(await getDojoClient(guild, 0, undefined, account.BuildLabel));
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { ISession, IFindSessionRequest } from "@/src/types/session";
|
import { ISession, IFindSessionRequest } from "@/src/types/session";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
|
import { JSONParse } from "json-with-bigint";
|
||||||
|
import { Types } from "mongoose";
|
||||||
|
|
||||||
const sessions: ISession[] = [];
|
const sessions: ISession[] = [];
|
||||||
|
|
||||||
function createNewSession(sessionData: ISession, Creator: string): ISession {
|
function createNewSession(sessionData: ISession, Creator: Types.ObjectId): ISession {
|
||||||
const sessionId = getNewSessionID();
|
const sessionId = new Types.ObjectId();
|
||||||
const newSession: ISession = {
|
const newSession: ISession = {
|
||||||
sessionId,
|
sessionId,
|
||||||
creatorId: Creator,
|
creatorId: Creator,
|
||||||
@ -25,7 +27,7 @@ function createNewSession(sessionData: ISession, Creator: string): ISession {
|
|||||||
customSettings: sessionData.customSettings || "",
|
customSettings: sessionData.customSettings || "",
|
||||||
rewardSeed: sessionData.rewardSeed || -1,
|
rewardSeed: sessionData.rewardSeed || -1,
|
||||||
guildId: sessionData.guildId || "",
|
guildId: sessionData.guildId || "",
|
||||||
buildId: sessionData.buildId || 4920386201513015989,
|
buildId: sessionData.buildId || 4920386201513015989n,
|
||||||
platform: sessionData.platform || 0,
|
platform: sessionData.platform || 0,
|
||||||
xplatform: sessionData.xplatform || true,
|
xplatform: sessionData.xplatform || true,
|
||||||
freePublic: sessionData.freePublic || 3,
|
freePublic: sessionData.freePublic || 3,
|
||||||
@ -40,13 +42,15 @@ function getAllSessions(): ISession[] {
|
|||||||
return sessions;
|
return sessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSessionByID(sessionId: string): ISession | undefined {
|
function getSessionByID(sessionId: string | Types.ObjectId): ISession | undefined {
|
||||||
return sessions.find(session => session.sessionId === sessionId);
|
return sessions.find(session => session.sessionId.equals(sessionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSession(sessionIdOrRequest: string | IFindSessionRequest): { createdBy: string; id: string }[] {
|
function getSession(
|
||||||
if (typeof sessionIdOrRequest === "string") {
|
sessionIdOrRequest: string | Types.ObjectId | IFindSessionRequest
|
||||||
const session = sessions.find(session => session.sessionId === sessionIdOrRequest);
|
): { createdBy: Types.ObjectId; id: Types.ObjectId }[] {
|
||||||
|
if (typeof sessionIdOrRequest === "string" || sessionIdOrRequest instanceof Types.ObjectId) {
|
||||||
|
const session = sessions.find(session => session.sessionId.equals(sessionIdOrRequest));
|
||||||
if (session) {
|
if (session) {
|
||||||
logger.debug("Found Sessions:", { session });
|
logger.debug("Found Sessions:", { session });
|
||||||
return [
|
return [
|
||||||
@ -79,35 +83,15 @@ function getSession(sessionIdOrRequest: string | IFindSessionRequest): { created
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSessionByCreatorID(creatorId: string): ISession | undefined {
|
function getSessionByCreatorID(creatorId: string | Types.ObjectId): ISession | undefined {
|
||||||
return sessions.find(session => session.creatorId === creatorId);
|
return sessions.find(session => session.creatorId.equals(creatorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNewSessionID(): string {
|
function updateSession(sessionId: string | Types.ObjectId, sessionData: string): boolean {
|
||||||
const characters = "0123456789abcdef";
|
const session = sessions.find(session => session.sessionId.equals(sessionId));
|
||||||
const maxAttempts = 100;
|
|
||||||
let sessionId = "";
|
|
||||||
|
|
||||||
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
||||||
sessionId = "64";
|
|
||||||
for (let i = 0; i < 22; i++) {
|
|
||||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
||||||
sessionId += characters[randomIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sessions.some(session => session.sessionId === sessionId)) {
|
|
||||||
return sessionId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error("Failed to generate a unique session ID");
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSession(sessionId: string, sessionData: string): boolean {
|
|
||||||
const session = sessions.find(session => session.sessionId === sessionId);
|
|
||||||
if (!session) return false;
|
if (!session) return false;
|
||||||
try {
|
try {
|
||||||
Object.assign(session, JSON.parse(sessionData));
|
Object.assign(session, JSONParse(sessionData));
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Invalid JSON string for session update.");
|
console.error("Invalid JSON string for session update.");
|
||||||
@ -115,8 +99,8 @@ function updateSession(sessionId: string, sessionData: string): boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSession(sessionId: string): boolean {
|
function deleteSession(sessionId: string | Types.ObjectId): boolean {
|
||||||
const index = sessions.findIndex(session => session.sessionId === sessionId);
|
const index = sessions.findIndex(session => session.sessionId.equals(sessionId));
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
sessions.splice(index, 1);
|
sessions.splice(index, 1);
|
||||||
return true;
|
return true;
|
||||||
@ -129,7 +113,6 @@ export {
|
|||||||
getAllSessions,
|
getAllSessions,
|
||||||
getSessionByID,
|
getSessionByID,
|
||||||
getSessionByCreatorID,
|
getSessionByCreatorID,
|
||||||
getNewSessionID,
|
|
||||||
updateSession,
|
updateSession,
|
||||||
deleteSession,
|
deleteSession,
|
||||||
getSession
|
getSession
|
||||||
|
@ -13,7 +13,8 @@ import {
|
|||||||
IDojoLeaderboardEntry,
|
IDojoLeaderboardEntry,
|
||||||
IGuildAdDatabase,
|
IGuildAdDatabase,
|
||||||
IAllianceDatabase,
|
IAllianceDatabase,
|
||||||
IAllianceMemberDatabase
|
IAllianceMemberDatabase,
|
||||||
|
GuildPermission
|
||||||
} 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";
|
||||||
@ -108,31 +109,31 @@ const defaultRanks: IGuildRank[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_General",
|
Name: "/Lotus/Language/Game/Rank_General",
|
||||||
Permissions: 4318
|
Permissions: GuildPermission.Host | 4318
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Officer",
|
Name: "/Lotus/Language/Game/Rank_Officer",
|
||||||
Permissions: 4314
|
Permissions: GuildPermission.Host | 4314
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Leader",
|
Name: "/Lotus/Language/Game/Rank_Leader",
|
||||||
Permissions: 4106
|
Permissions: GuildPermission.Host | 4106
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Sage",
|
Name: "/Lotus/Language/Game/Rank_Sage",
|
||||||
Permissions: 4304
|
Permissions: GuildPermission.Host | 4304
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Soldier",
|
Name: "/Lotus/Language/Game/Rank_Soldier",
|
||||||
Permissions: 4098
|
Permissions: GuildPermission.Host | 4098
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Initiate",
|
Name: "/Lotus/Language/Game/Rank_Initiate",
|
||||||
Permissions: 4096
|
Permissions: GuildPermission.Host | GuildPermission.Fabricator
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "/Lotus/Language/Game/Rank_Utility",
|
Name: "/Lotus/Language/Game/Rank_Utility",
|
||||||
Permissions: 4096
|
Permissions: GuildPermission.Host | GuildPermission.Fabricator
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@ import { config } from "./configService";
|
|||||||
import { Account } from "../models/loginModel";
|
import { Account } from "../models/loginModel";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { Friendship } from "../models/friendModel";
|
import { Friendship } from "../models/friendModel";
|
||||||
import { toMongoDate } from "../helpers/inventoryHelpers";
|
import { fromOid, toMongoDate } from "../helpers/inventoryHelpers";
|
||||||
|
|
||||||
export const addAccountDataToFriendInfo = async (info: IFriendInfo): Promise<void> => {
|
export const addAccountDataToFriendInfo = async (info: IFriendInfo): Promise<void> => {
|
||||||
const account = (await Account.findById(info._id.$oid, "DisplayName LastLogin"))!;
|
const account = (await Account.findById(fromOid(info._id), "DisplayName LastLogin"))!;
|
||||||
info.DisplayName = account.DisplayName;
|
info.DisplayName = account.DisplayName;
|
||||||
info.LastLogin = toMongoDate(account.LastLogin);
|
info.LastLogin = toMongoDate(account.LastLogin);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addInventoryDataToFriendInfo = async (info: IFriendInfo): Promise<void> => {
|
export const addInventoryDataToFriendInfo = async (info: IFriendInfo): Promise<void> => {
|
||||||
const inventory = await getInventory(info._id.$oid, "PlayerLevel ActiveAvatarImageType");
|
const inventory = await getInventory(fromOid(info._id), "PlayerLevel ActiveAvatarImageType");
|
||||||
info.PlayerLevel = config.spoofMasteryRank == -1 ? inventory.PlayerLevel : config.spoofMasteryRank;
|
info.PlayerLevel = config.spoofMasteryRank == -1 ? inventory.PlayerLevel : config.spoofMasteryRank;
|
||||||
info.ActiveAvatarImageType = inventory.ActiveAvatarImageType;
|
info.ActiveAvatarImageType = inventory.ActiveAvatarImageType;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest, TAccountDocument } from "@/src/services/loginService";
|
||||||
import { addLevelKeys, addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
|
import { addLevelKeys, addRecipes, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
|
||||||
import { Alliance, AllianceMember, Guild, GuildAd, GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
|
import { Alliance, AllianceMember, Guild, GuildAd, GuildMember, TGuildDatabaseDocument } from "@/src/models/guildModel";
|
||||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
@ -19,7 +19,7 @@ import {
|
|||||||
IGuildVault,
|
IGuildVault,
|
||||||
ITechProjectDatabase
|
ITechProjectDatabase
|
||||||
} from "@/src/types/guildTypes";
|
} from "@/src/types/guildTypes";
|
||||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
import { toMongoDate, toOid, toOid2 } from "@/src/helpers/inventoryHelpers";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { ExportDojoRecipes, ExportResources, IDojoBuild, IDojoResearch } from "warframe-public-export-plus";
|
import { ExportDojoRecipes, ExportResources, IDojoBuild, IDojoResearch } from "warframe-public-export-plus";
|
||||||
import { logger } from "../utils/logger";
|
import { logger } from "../utils/logger";
|
||||||
@ -54,7 +54,10 @@ export const getGuildForRequestEx = async (
|
|||||||
return guild;
|
return guild;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getGuildClient = async (guild: TGuildDatabaseDocument, accountId: string): Promise<IGuildClient> => {
|
export const getGuildClient = async (
|
||||||
|
guild: TGuildDatabaseDocument,
|
||||||
|
account: TAccountDocument
|
||||||
|
): Promise<IGuildClient> => {
|
||||||
const guildMembers = await GuildMember.find({ guildId: guild._id });
|
const guildMembers = await GuildMember.find({ guildId: guild._id });
|
||||||
|
|
||||||
const members: IGuildMemberClient[] = [];
|
const members: IGuildMemberClient[] = [];
|
||||||
@ -62,13 +65,13 @@ export const getGuildClient = async (guild: TGuildDatabaseDocument, accountId: s
|
|||||||
const dataFillInPromises: Promise<void>[] = [];
|
const dataFillInPromises: Promise<void>[] = [];
|
||||||
for (const guildMember of guildMembers) {
|
for (const guildMember of guildMembers) {
|
||||||
const member: IGuildMemberClient = {
|
const member: IGuildMemberClient = {
|
||||||
_id: toOid(guildMember.accountId),
|
_id: toOid2(guildMember.accountId, account.BuildLabel),
|
||||||
Rank: guildMember.rank,
|
Rank: guildMember.rank,
|
||||||
Status: guildMember.status,
|
Status: guildMember.status,
|
||||||
Note: guildMember.RequestMsg,
|
Note: guildMember.RequestMsg,
|
||||||
RequestExpiry: guildMember.RequestExpiry ? toMongoDate(guildMember.RequestExpiry) : undefined
|
RequestExpiry: guildMember.RequestExpiry ? toMongoDate(guildMember.RequestExpiry) : undefined
|
||||||
};
|
};
|
||||||
if (guildMember.accountId.equals(accountId)) {
|
if (guildMember.accountId.equals(account._id)) {
|
||||||
missingEntry = false;
|
missingEntry = false;
|
||||||
} else {
|
} else {
|
||||||
dataFillInPromises.push(addAccountDataToFriendInfo(member));
|
dataFillInPromises.push(addAccountDataToFriendInfo(member));
|
||||||
@ -79,13 +82,13 @@ export const getGuildClient = async (guild: TGuildDatabaseDocument, accountId: s
|
|||||||
if (missingEntry) {
|
if (missingEntry) {
|
||||||
// Handle clans created prior to creation of the GuildMember model.
|
// Handle clans created prior to creation of the GuildMember model.
|
||||||
await GuildMember.insertOne({
|
await GuildMember.insertOne({
|
||||||
accountId: accountId,
|
accountId: account._id,
|
||||||
guildId: guild._id,
|
guildId: guild._id,
|
||||||
status: 0,
|
status: 0,
|
||||||
rank: 0
|
rank: 0
|
||||||
});
|
});
|
||||||
members.push({
|
members.push({
|
||||||
_id: { $oid: accountId },
|
_id: toOid2(account._id, account.BuildLabel),
|
||||||
Status: 0,
|
Status: 0,
|
||||||
Rank: 0
|
Rank: 0
|
||||||
});
|
});
|
||||||
@ -94,7 +97,7 @@ export const getGuildClient = async (guild: TGuildDatabaseDocument, accountId: s
|
|||||||
await Promise.all(dataFillInPromises);
|
await Promise.all(dataFillInPromises);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_id: toOid(guild._id),
|
_id: toOid2(guild._id, account.BuildLabel),
|
||||||
Name: guild.Name,
|
Name: guild.Name,
|
||||||
MOTD: guild.MOTD,
|
MOTD: guild.MOTD,
|
||||||
LongMOTD: guild.LongMOTD,
|
LongMOTD: guild.LongMOTD,
|
||||||
@ -106,11 +109,11 @@ export const getGuildClient = async (guild: TGuildDatabaseDocument, accountId: s
|
|||||||
ActiveDojoColorResearch: guild.ActiveDojoColorResearch,
|
ActiveDojoColorResearch: guild.ActiveDojoColorResearch,
|
||||||
Class: guild.Class,
|
Class: guild.Class,
|
||||||
XP: guild.XP,
|
XP: guild.XP,
|
||||||
IsContributor: !!guild.CeremonyContributors?.find(x => x.equals(accountId)),
|
IsContributor: !!guild.CeremonyContributors?.find(x => x.equals(account._id)),
|
||||||
NumContributors: guild.CeremonyContributors?.length ?? 0,
|
NumContributors: guild.CeremonyContributors?.length ?? 0,
|
||||||
CeremonyResetDate: guild.CeremonyResetDate ? toMongoDate(guild.CeremonyResetDate) : undefined,
|
CeremonyResetDate: guild.CeremonyResetDate ? toMongoDate(guild.CeremonyResetDate) : undefined,
|
||||||
AutoContributeFromVault: guild.AutoContributeFromVault,
|
AutoContributeFromVault: guild.AutoContributeFromVault,
|
||||||
AllianceId: guild.AllianceId ? toOid(guild.AllianceId) : undefined
|
AllianceId: guild.AllianceId ? toOid2(guild.AllianceId, account.BuildLabel) : undefined
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -130,10 +133,11 @@ export const getGuildVault = (guild: TGuildDatabaseDocument): IGuildVault => {
|
|||||||
export const getDojoClient = async (
|
export const getDojoClient = async (
|
||||||
guild: TGuildDatabaseDocument,
|
guild: TGuildDatabaseDocument,
|
||||||
status: number,
|
status: number,
|
||||||
componentId?: Types.ObjectId | string
|
componentId?: Types.ObjectId | string,
|
||||||
|
buildLabel?: string
|
||||||
): Promise<IDojoClient> => {
|
): Promise<IDojoClient> => {
|
||||||
const dojo: IDojoClient = {
|
const dojo: IDojoClient = {
|
||||||
_id: { $oid: guild._id.toString() },
|
_id: toOid2(guild._id, buildLabel),
|
||||||
Name: guild.Name,
|
Name: guild.Name,
|
||||||
Tier: guild.Tier,
|
Tier: guild.Tier,
|
||||||
GuildEmblem: guild.Emblem,
|
GuildEmblem: guild.Emblem,
|
||||||
@ -155,8 +159,8 @@ export const getDojoClient = async (
|
|||||||
for (const dojoComponent of guild.DojoComponents) {
|
for (const dojoComponent of guild.DojoComponents) {
|
||||||
if (!componentId || dojoComponent._id.equals(componentId)) {
|
if (!componentId || dojoComponent._id.equals(componentId)) {
|
||||||
const clientComponent: IDojoComponentClient = {
|
const clientComponent: IDojoComponentClient = {
|
||||||
id: toOid(dojoComponent._id),
|
id: toOid2(dojoComponent._id, buildLabel),
|
||||||
SortId: toOid(dojoComponent.SortId ?? dojoComponent._id), // always providing a SortId so decos don't need repositioning to reparent
|
SortId: toOid2(dojoComponent.SortId ?? dojoComponent._id, buildLabel), // always providing a SortId so decos don't need repositioning to reparent
|
||||||
pf: dojoComponent.pf,
|
pf: dojoComponent.pf,
|
||||||
ppf: dojoComponent.ppf,
|
ppf: dojoComponent.ppf,
|
||||||
Name: dojoComponent.Name,
|
Name: dojoComponent.Name,
|
||||||
@ -165,7 +169,7 @@ export const getDojoClient = async (
|
|||||||
Settings: dojoComponent.Settings
|
Settings: dojoComponent.Settings
|
||||||
};
|
};
|
||||||
if (dojoComponent.pi) {
|
if (dojoComponent.pi) {
|
||||||
clientComponent.pi = toOid(dojoComponent.pi);
|
clientComponent.pi = toOid2(dojoComponent.pi, buildLabel);
|
||||||
clientComponent.op = dojoComponent.op!;
|
clientComponent.op = dojoComponent.op!;
|
||||||
clientComponent.pp = dojoComponent.pp!;
|
clientComponent.pp = dojoComponent.pp!;
|
||||||
}
|
}
|
||||||
@ -221,7 +225,7 @@ export const getDojoClient = async (
|
|||||||
clientComponent.Decos = [];
|
clientComponent.Decos = [];
|
||||||
for (const deco of dojoComponent.Decos) {
|
for (const deco of dojoComponent.Decos) {
|
||||||
const clientDeco: IDojoDecoClient = {
|
const clientDeco: IDojoDecoClient = {
|
||||||
id: toOid(deco._id),
|
id: toOid2(deco._id, buildLabel),
|
||||||
Type: deco.Type,
|
Type: deco.Type,
|
||||||
Pos: deco.Pos,
|
Pos: deco.Pos,
|
||||||
Rot: deco.Rot,
|
Rot: deco.Rot,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { IMongoDate, IOid } from "./commonTypes";
|
import { IMongoDate, IOidWithLegacySupport } from "./commonTypes";
|
||||||
|
|
||||||
export interface IFriendInfo {
|
export interface IFriendInfo {
|
||||||
_id: IOid;
|
_id: IOidWithLegacySupport;
|
||||||
DisplayName?: string;
|
DisplayName?: string;
|
||||||
PlatformNames?: string[];
|
PlatformNames?: string[];
|
||||||
PlatformAccountId?: string;
|
PlatformAccountId?: string;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { IOid, IMongoDate } from "@/src/types/commonTypes";
|
import { IOid, IMongoDate, IOidWithLegacySupport } from "@/src/types/commonTypes";
|
||||||
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IPictureFrameInfo } from "./shipTypes";
|
import { IPictureFrameInfo } from "./shipTypes";
|
||||||
import { IFriendInfo } from "./friendTypes";
|
import { IFriendInfo } from "./friendTypes";
|
||||||
|
|
||||||
export interface IGuildClient {
|
export interface IGuildClient {
|
||||||
_id: IOid;
|
_id: IOidWithLegacySupport;
|
||||||
Name: string;
|
Name: string;
|
||||||
MOTD: string;
|
MOTD: string;
|
||||||
LongMOTD?: ILongMOTD;
|
LongMOTD?: ILongMOTD;
|
||||||
@ -22,7 +22,7 @@ export interface IGuildClient {
|
|||||||
CeremonyResetDate?: IMongoDate;
|
CeremonyResetDate?: IMongoDate;
|
||||||
CrossPlatformEnabled?: boolean;
|
CrossPlatformEnabled?: boolean;
|
||||||
AutoContributeFromVault?: boolean;
|
AutoContributeFromVault?: boolean;
|
||||||
AllianceId?: IOid;
|
AllianceId?: IOidWithLegacySupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGuildDatabase {
|
export interface IGuildDatabase {
|
||||||
@ -71,7 +71,6 @@ export interface ILongMOTD {
|
|||||||
authorGuildName?: string;
|
authorGuildName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 32 seems to be reserved
|
|
||||||
export enum GuildPermission {
|
export enum GuildPermission {
|
||||||
Ruler = 1, // Clan: Change hierarchy. Alliance (Creator only): Kick clans.
|
Ruler = 1, // Clan: Change hierarchy. Alliance (Creator only): Kick clans.
|
||||||
Advertiser = 8192,
|
Advertiser = 8192,
|
||||||
@ -79,6 +78,7 @@ export enum GuildPermission {
|
|||||||
Regulator = 4, // Kick members
|
Regulator = 4, // Kick members
|
||||||
Promoter = 8, // Clan: Promote and demote members. Alliance (Creator only): Change clan permissions.
|
Promoter = 8, // Clan: Promote and demote members. Alliance (Creator only): Change clan permissions.
|
||||||
Architect = 16, // Create and destroy rooms
|
Architect = 16, // Create and destroy rooms
|
||||||
|
Host = 32, // No longer used in modern versions
|
||||||
Decorator = 1024, // Create and destroy decos
|
Decorator = 1024, // Create and destroy decos
|
||||||
Treasurer = 64, // Clan: Contribute from vault and edit tax rate. Alliance: Divvy vault.
|
Treasurer = 64, // Clan: Contribute from vault and edit tax rate. Alliance: Divvy vault.
|
||||||
Tech = 128, // Queue research
|
Tech = 128, // Queue research
|
||||||
@ -127,13 +127,13 @@ export interface IGuildVault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDojoClient {
|
export interface IDojoClient {
|
||||||
_id: IOid; // ID of the guild
|
_id: IOidWithLegacySupport; // ID of the guild
|
||||||
Name: string;
|
Name: string;
|
||||||
Tier: number;
|
Tier: number;
|
||||||
TradeTax?: number;
|
TradeTax?: number;
|
||||||
FixedContributions: boolean;
|
FixedContributions: boolean;
|
||||||
DojoRevision: number;
|
DojoRevision: number;
|
||||||
AllianceId?: IOid;
|
AllianceId?: IOidWithLegacySupport;
|
||||||
Vault?: IGuildVault;
|
Vault?: IGuildVault;
|
||||||
Class?: number; // Level
|
Class?: number; // Level
|
||||||
RevisionTime: number;
|
RevisionTime: number;
|
||||||
@ -148,11 +148,11 @@ export interface IDojoClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDojoComponentClient {
|
export interface IDojoComponentClient {
|
||||||
id: IOid;
|
id: IOidWithLegacySupport;
|
||||||
SortId?: IOid;
|
SortId?: IOidWithLegacySupport;
|
||||||
pf: string; // Prefab (.level)
|
pf: string; // Prefab (.level)
|
||||||
ppf: string;
|
ppf: string;
|
||||||
pi?: IOid; // Parent ID. N/A to root.
|
pi?: IOidWithLegacySupport; // Parent ID. N/A to root.
|
||||||
op?: string; // Name of the door within this room that leads to its parent. N/A to root.
|
op?: string; // Name of the door within this room that leads to its parent. N/A to root.
|
||||||
pp?: string; // Name of the door within the parent that leads to this room. N/A to root.
|
pp?: string; // Name of the door within the parent that leads to this room. N/A to root.
|
||||||
Name?: string;
|
Name?: string;
|
||||||
@ -166,7 +166,7 @@ export interface IDojoComponentClient {
|
|||||||
DestructionTimeRemaining?: number; // old versions
|
DestructionTimeRemaining?: number; // old versions
|
||||||
Decos?: IDojoDecoClient[];
|
Decos?: IDojoDecoClient[];
|
||||||
DecoCapacity?: number;
|
DecoCapacity?: number;
|
||||||
PaintBot?: IOid;
|
PaintBot?: IOidWithLegacySupport;
|
||||||
PendingColors?: number[];
|
PendingColors?: number[];
|
||||||
Colors?: number[];
|
Colors?: number[];
|
||||||
PendingLights?: number[];
|
PendingLights?: number[];
|
||||||
@ -191,7 +191,7 @@ export interface IDojoComponentDatabase
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDojoDecoClient {
|
export interface IDojoDecoClient {
|
||||||
id: IOid;
|
id: IOidWithLegacySupport;
|
||||||
Type: string;
|
Type: string;
|
||||||
Pos: number[];
|
Pos: number[];
|
||||||
Rot: number[];
|
Rot: number[];
|
||||||
@ -285,7 +285,7 @@ export interface IGuildAdDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IAllianceClient {
|
export interface IAllianceClient {
|
||||||
_id: IOid;
|
_id: IOidWithLegacySupport;
|
||||||
Name: string;
|
Name: string;
|
||||||
MOTD?: ILongMOTD;
|
MOTD?: ILongMOTD;
|
||||||
LongMOTD?: ILongMOTD;
|
LongMOTD?: ILongMOTD;
|
||||||
@ -306,7 +306,7 @@ export interface IAllianceDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IAllianceMemberClient {
|
export interface IAllianceMemberClient {
|
||||||
_id: IOid;
|
_id: IOidWithLegacySupport;
|
||||||
Name: string;
|
Name: string;
|
||||||
Tier: number;
|
Tier: number;
|
||||||
Pending: boolean;
|
Pending: boolean;
|
||||||
@ -314,7 +314,7 @@ export interface IAllianceMemberClient {
|
|||||||
Permissions: number;
|
Permissions: number;
|
||||||
MemberCount: number;
|
MemberCount: number;
|
||||||
ClanLeader?: string;
|
ClanLeader?: string;
|
||||||
ClanLeaderId?: IOid;
|
ClanLeaderId?: IOidWithLegacySupport;
|
||||||
OriginalPlatform?: number;
|
OriginalPlatform?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
import { Types } from "mongoose";
|
||||||
|
|
||||||
export interface ISession {
|
export interface ISession {
|
||||||
sessionId: string;
|
sessionId: Types.ObjectId;
|
||||||
creatorId: string;
|
creatorId: Types.ObjectId;
|
||||||
maxPlayers?: number;
|
maxPlayers?: number;
|
||||||
minPlayers?: number;
|
minPlayers?: number;
|
||||||
privateSlots?: number;
|
privateSlots?: number;
|
||||||
@ -18,7 +20,7 @@ export interface ISession {
|
|||||||
customSettings?: string;
|
customSettings?: string;
|
||||||
rewardSeed?: number;
|
rewardSeed?: number;
|
||||||
guildId?: string;
|
guildId?: string;
|
||||||
buildId?: number;
|
buildId?: number | bigint;
|
||||||
platform?: number;
|
platform?: number;
|
||||||
xplatform?: boolean;
|
xplatform?: boolean;
|
||||||
freePublic?: number;
|
freePublic?: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user