Fix display names for XMPP

This commit is contained in:
Lawin0129
2022-03-06 20:39:18 +00:00
parent 4e6881e219
commit 8cf7e405bf
4 changed files with 19 additions and 94 deletions

View File

@@ -1,12 +0,0 @@
[
{
"id": "SubtoLawin_123",
"displayName": "Subscribe to Lawin on YouTube!",
"externalAuths": {}
},
{
"id": "Followlawin_123",
"displayName": "Follow @lawin_010 on twitter!",
"externalAuths": {}
}
]

View File

@@ -1,16 +1 @@
[ []
{
"accountId": "SubtoLawin_123",
"status": "ACCEPTED",
"direction": "OUTBOUND",
"created": "2000-05-11T15:53:53.072Z",
"favorite": false
},
{
"accountId": "Followlawin_123",
"status": "ACCEPTED",
"direction": "OUTBOUND",
"created": "2000-04-08T12:32:42.069Z",
"favorite": false
}
]

View File

@@ -1,24 +1,5 @@
{ {
"friends": [ "friends": [],
{
"accountId": "SubtoLawin_123",
"groups": [],
"mutual": 0,
"alias": "",
"note": "",
"favorite": false,
"created": "2000-04-08T12:32:42.069Z"
},
{
"accountId": "Followlawin_123",
"groups": [],
"mutual": 0,
"alias": "",
"note": "",
"favorite": false,
"created": "2000-04-08T12:32:42.069Z"
}
],
"incoming": [], "incoming": [],
"outgoing": [], "outgoing": [],
"suggested": [], "suggested": [],

View File

@@ -4,64 +4,35 @@ const fs = require("fs");
const path = require("path"); const path = require("path");
const iniparser = require("ini"); const iniparser = require("ini");
const config = iniparser.parse(fs.readFileSync(path.join(__dirname, "..", "Config", "config.ini")).toString()); const config = iniparser.parse(fs.readFileSync(path.join(__dirname, "..", "Config", "config.ini")).toString());
const functions = require("./functions.js");
const accounts = require("./../responses/account.json");
var Memory_CurrentAccountID = config.Config.displayName; var Memory_CurrentAccountID = config.Config.displayName;
express.get("/account/api/public/account", async (req, res) => { express.get("/account/api/public/account", async (req, res) => {
var response = []; var response = [];
if (Memory_CurrentAccountID.includes("@")) Memory_CurrentAccountID = Memory_CurrentAccountID.split("@")[0];
if (config.Config.bUseConfigDisplayName == false) {
if (typeof req.query.accountId == "string") {
Memory_CurrentAccountID = req.query.accountId;
if (Memory_CurrentAccountID.includes("@")) Memory_CurrentAccountID = Memory_CurrentAccountID.split("@")[0];
if (!accounts.find(i => i.id == req.query.accountId)) {
accounts.push({
"id": req.query.accountId,
"displayName": Memory_CurrentAccountID,
"externalAuths": {}
})
}
if (accounts.find(i => i.id == req.query.accountId).displayName != Memory_CurrentAccountID) {
var index = accounts.findIndex(i => i.id == req.query.accountId);
accounts[index].displayName = Memory_CurrentAccountID;
}
}
} else if (typeof req.query.accountId == "string") {
if (!accounts.find(i => i.id == req.query.accountId)) {
accounts.push({
"id": req.query.accountId,
"displayName": Memory_CurrentAccountID,
"externalAuths": {}
})
}
if (accounts.find(i => i.id == req.query.accountId).displayName != Memory_CurrentAccountID) {
var index = accounts.findIndex(i => i.id == req.query.accountId);
accounts[index].displayName = Memory_CurrentAccountID;
}
}
if (typeof req.query.accountId == "string") { if (typeof req.query.accountId == "string") {
if (accounts.find(i => i.id == req.query.accountId)) { var accountId = req.query.accountId;
response.push(accounts.find(i => i.id == req.query.accountId)) if (accountId.includes("@")) accountId = accountId.split("@")[0];
}
response.push({
"id": accountId,
"displayName": accountId,
"externalAuths": {}
})
} }
if (Array.isArray(req.query.accountId)) { if (Array.isArray(req.query.accountId)) {
for (var x in req.query.accountId) { for (var x in req.query.accountId) {
if (accounts.find(i => i.id == req.query.accountId[x])) { var accountId = req.query.accountId[x];
response.push(accounts.find(i => i.id == req.query.accountId[x])) if (accountId.includes("@")) accountId = accountId.split("@")[0];
}
response.push({
"id": accountId,
"displayName": accountId,
"externalAuths": {}
})
} }
} }
fs.writeFileSync("./responses/account.json", JSON.stringify(accounts, null, 2));
res.json(response) res.json(response)
}) })
@@ -171,4 +142,4 @@ express.post("/fortnite/api/game/v2/tryPlayOnPlatform/account/*", async (req, re
res.send(true); res.send(true);
}) })
module.exports = express; module.exports = express;