mirror of
https://github.com/Lawin0129/LawinServer.git
synced 2026-01-13 02:42:22 +01:00
Fix display names for XMPP
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
[
|
||||
{
|
||||
"id": "SubtoLawin_123",
|
||||
"displayName": "Subscribe to Lawin on YouTube!",
|
||||
"externalAuths": {}
|
||||
},
|
||||
{
|
||||
"id": "Followlawin_123",
|
||||
"displayName": "Follow @lawin_010 on twitter!",
|
||||
"externalAuths": {}
|
||||
}
|
||||
]
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
[]
|
||||
@@ -1,24 +1,5 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"friends": [],
|
||||
"incoming": [],
|
||||
"outgoing": [],
|
||||
"suggested": [],
|
||||
|
||||
@@ -4,63 +4,34 @@ const fs = require("fs");
|
||||
const path = require("path");
|
||||
const iniparser = require("ini");
|
||||
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;
|
||||
|
||||
express.get("/account/api/public/account", async (req, res) => {
|
||||
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];
|
||||
var accountId = req.query.accountId;
|
||||
if (accountId.includes("@")) accountId = accountId.split("@")[0];
|
||||
|
||||
if (!accounts.find(i => i.id == req.query.accountId)) {
|
||||
accounts.push({
|
||||
"id": req.query.accountId,
|
||||
"displayName": Memory_CurrentAccountID,
|
||||
response.push({
|
||||
"id": accountId,
|
||||
"displayName": accountId,
|
||||
"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 (accounts.find(i => i.id == req.query.accountId)) {
|
||||
response.push(accounts.find(i => i.id == req.query.accountId))
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(req.query.accountId)) {
|
||||
for (var x in req.query.accountId) {
|
||||
if (accounts.find(i => i.id == req.query.accountId[x])) {
|
||||
response.push(accounts.find(i => i.id == req.query.accountId[x]))
|
||||
}
|
||||
}
|
||||
}
|
||||
var accountId = req.query.accountId[x];
|
||||
if (accountId.includes("@")) accountId = accountId.split("@")[0];
|
||||
|
||||
fs.writeFileSync("./responses/account.json", JSON.stringify(accounts, null, 2));
|
||||
response.push({
|
||||
"id": accountId,
|
||||
"displayName": accountId,
|
||||
"externalAuths": {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
res.json(response)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user