mirror of
https://github.com/Lawin0129/LawinServer.git
synced 2026-01-13 02:42:22 +01:00
Added support for viewing the Battle & OG passes in the Passes Tab. (33.00+)
This commit is contained in:
@@ -47,6 +47,13 @@ express.get("/content/api/pages/fortnite-game/radio-stations", async (req, res)
|
||||
})
|
||||
})
|
||||
|
||||
express.get("/content/api/pages/fortnite-game/seasonpasses", async (req, res) => {
|
||||
const seasonPasses = require("./../responses/Athena/seasonPasses.json");
|
||||
functions.chooseTranslationsInJSON(seasonPasses, req)
|
||||
|
||||
res.json(seasonPasses)
|
||||
})
|
||||
|
||||
express.get("/content/api/pages/*", async (req, res) => {
|
||||
const contentpages = functions.getContentPages(req);
|
||||
|
||||
@@ -56,7 +63,7 @@ express.get("/content/api/pages/*", async (req, res) => {
|
||||
express.post("/api/v1/fortnite-br/*/target", async (req, res) => {
|
||||
const motd = JSON.parse(JSON.stringify(require("./../responses/Athena/motd.json")));
|
||||
var language = req.body.language || req.body.parameters.language;
|
||||
functions.chooseTranslationsInJSON(motd, language)
|
||||
functions.chooseTranslationsInJSON(motd, req, language)
|
||||
|
||||
if (req.body.hasOwnProperty("tags")) {
|
||||
motd.contentItems.forEach(item => {
|
||||
|
||||
@@ -203,10 +203,21 @@ function getTheater(req) {
|
||||
return theater;
|
||||
}
|
||||
|
||||
function chooseTranslationsInJSON(obj, targetLanguage = "en") {
|
||||
function chooseTranslationsInJSON(obj, req, targetLanguage = "") {
|
||||
if (!targetLanguage) {
|
||||
if (req.headers["accept-language"]) {
|
||||
if (req.headers["accept-language"].includes("-") && req.headers["accept-language"] != "es-419" && req.headers["accept-language"] != "pt-BR") {
|
||||
targetLanguage = req.headers["accept-language"].split("-")[0];
|
||||
} else {
|
||||
targetLanguage = req.headers["accept-language"];
|
||||
}
|
||||
} else {
|
||||
targetLanguage = "en";
|
||||
}
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
chooseTranslationsInJSON(obj[i], targetLanguage);
|
||||
chooseTranslationsInJSON(obj[i], req, targetLanguage);
|
||||
}
|
||||
} else if (typeof obj === "object" && obj !== null) {
|
||||
for (const key in obj) {
|
||||
@@ -214,7 +225,7 @@ function chooseTranslationsInJSON(obj, targetLanguage = "en") {
|
||||
if (obj[key][targetLanguage] || obj[key]["en"]) {
|
||||
obj[key] = obj[key][targetLanguage] || obj[key]["en"];
|
||||
} else {
|
||||
chooseTranslationsInJSON(obj[key], targetLanguage);
|
||||
chooseTranslationsInJSON(obj[key], req, targetLanguage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,17 +237,7 @@ function getContentPages(req) {
|
||||
|
||||
const contentpages = JSON.parse(JSON.stringify(require("./../responses/contentpages.json")));
|
||||
|
||||
var Language = "en";
|
||||
|
||||
if (req.headers["accept-language"]) {
|
||||
if (req.headers["accept-language"].includes("-") && req.headers["accept-language"] != "es-419" && req.headers["accept-language"] != "pt-BR") {
|
||||
Language = req.headers["accept-language"].split("-")[0];
|
||||
} else {
|
||||
Language = req.headers["accept-language"];
|
||||
}
|
||||
}
|
||||
|
||||
chooseTranslationsInJSON(contentpages, Language)
|
||||
chooseTranslationsInJSON(contentpages, req)
|
||||
|
||||
const news = ["savetheworldnews", "battleroyalenews"];
|
||||
try {
|
||||
|
||||
@@ -7375,6 +7375,70 @@ express.post("/fortnite/api/game/v2/profile/*/client/PurchaseCatalogEntry", asyn
|
||||
res.end();
|
||||
});
|
||||
|
||||
// Set auto claim for a season pass
|
||||
express.post("/fortnite/api/game/v2/profile/*/client/SetSeasonPassAutoClaim", async (req, res) => {
|
||||
const profile = require(`./../profiles/${req.query.profileId || "athena"}.json`);
|
||||
|
||||
// do not change any of these or you will end up breaking it
|
||||
var ApplyProfileChanges = [];
|
||||
var BaseRevision = profile.rvn || 0;
|
||||
var QueryRevision = req.query.rvn || -1;
|
||||
var StatChanged = false;
|
||||
|
||||
if (req.body.seasonIds && req.body.bEnabled !== undefined) {
|
||||
for (var seasonId of req.body.seasonIds) {
|
||||
if (!profile.stats.attributes.hasOwnProperty("auto_spend_season_currency_ids")) {
|
||||
profile.stats.attributes.auto_spend_season_currency_ids = [];
|
||||
}
|
||||
|
||||
if (req.body.bEnabled === true) {
|
||||
if (!profile.stats.attributes.auto_spend_season_currency_ids.includes(seasonId)) {
|
||||
profile.stats.attributes.auto_spend_season_currency_ids.push(seasonId);
|
||||
StatChanged = true;
|
||||
}
|
||||
} else {
|
||||
let index = profile.stats.attributes.auto_spend_season_currency_ids.indexOf(seasonId);
|
||||
if (index !== -1) {
|
||||
profile.stats.attributes.auto_spend_season_currency_ids.splice(index, 1);
|
||||
StatChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StatChanged == true) {
|
||||
ApplyProfileChanges.push({
|
||||
"changeType": "statModified",
|
||||
"name": "auto_spend_season_currency_ids",
|
||||
"value": profile.stats.attributes.auto_spend_season_currency_ids
|
||||
})
|
||||
|
||||
profile.rvn += 1;
|
||||
profile.commandRevision += 1;
|
||||
|
||||
fs.writeFileSync(`./profiles/${req.query.profileId || "athena"}.json`, JSON.stringify(profile, null, 2));
|
||||
}
|
||||
|
||||
// this doesn't work properly on version v12.20 and above but whatever
|
||||
if (QueryRevision != BaseRevision) {
|
||||
ApplyProfileChanges = [{
|
||||
"changeType": "fullProfileUpdate",
|
||||
"profile": profile
|
||||
}];
|
||||
}
|
||||
|
||||
res.json({
|
||||
"profileRevision": profile.rvn || 0,
|
||||
"profileId": req.query.profileId || "athena",
|
||||
"profileChangesBaseRevision": BaseRevision,
|
||||
"profileChanges": ApplyProfileChanges,
|
||||
"profileCommandRevision": profile.commandRevision || 0,
|
||||
"serverTime": new Date().toISOString(),
|
||||
"responseVersion": 1
|
||||
})
|
||||
res.end();
|
||||
});
|
||||
|
||||
// Archive locker items
|
||||
express.post("/fortnite/api/game/v2/profile/*/client/SetItemArchivedStatusBatch", async (req, res) => {
|
||||
const profile = require(`./../profiles/${req.query.profileId || "athena"}.json`);
|
||||
|
||||
Reference in New Issue
Block a user