feat: hide game masters
This commit is contained in:
parent
04ea344bb2
commit
1fd6b326dc
8 changed files with 201 additions and 4213 deletions
|
|
@ -157,7 +157,7 @@ export class CharacterController {
|
|||
return;
|
||||
}
|
||||
|
||||
const charData = await this.getCharacterData(realmName, charName);
|
||||
const charData = await this.getCharacterData(realm, charName);
|
||||
if (charData === null) {
|
||||
// Could not find character
|
||||
res.sendStatus(404);
|
||||
|
|
@ -203,7 +203,7 @@ export class CharacterController {
|
|||
return;
|
||||
}
|
||||
|
||||
const charData = await this.getCharacterData(realm.name, charName);
|
||||
const charData = await this.getCharacterData(realm, charName);
|
||||
if (charData === null) {
|
||||
// Could not find character
|
||||
res.sendStatus(404);
|
||||
|
|
@ -232,7 +232,7 @@ export class CharacterController {
|
|||
return;
|
||||
}
|
||||
|
||||
const charData = await this.getCharacterData(realm.name, charName);
|
||||
const charData = await this.getCharacterData(realm, charName);
|
||||
if (charData === null) {
|
||||
// Could not find character
|
||||
res.sendStatus(404);
|
||||
|
|
@ -256,7 +256,7 @@ export class CharacterController {
|
|||
return;
|
||||
}
|
||||
|
||||
const charData = await this.getCharacterData(realm.name, character);
|
||||
const charData = await this.getCharacterData(realm, character);
|
||||
if (charData === null) {
|
||||
// Could not find character
|
||||
res.sendStatus(404);
|
||||
|
|
@ -285,13 +285,16 @@ export class CharacterController {
|
|||
return this.armory.config.realms.find(r => r.name.toLowerCase() === realm.toLowerCase());
|
||||
}
|
||||
|
||||
private async getCharacterData(realm: string, character: string | number): Promise<ICharacterData> {
|
||||
private async getCharacterData(realm: IRealmConfig, character: string | number): Promise<ICharacterData> {
|
||||
const where = typeof character === "string" ? "LOWER(name) = LOWER(?)" : "guid = ?";
|
||||
const [rows, fields] = await this.armory.getCharactersDb(realm).query(`
|
||||
SELECT guid, name, race, class, gender, level, skin, face, hairStyle, hairColor, facialStyle, playerFlags, online
|
||||
FROM characters
|
||||
WHERE ${where}
|
||||
`, [character]);
|
||||
const [rows, fields] = await this.armory.getCharactersDb(realm.name).query(`
|
||||
SELECT \`guid\`, \`name\`, \`race\`, \`class\`, \`gender\`, \`level\`, \`skin\`, \`face\`, \`hairStyle\`, \`hairColor\`, \`facialStyle\`, \`playerFlags\`, \`online\`
|
||||
FROM \`characters\`
|
||||
LEFT JOIN \`${realm.authDatabase}\`.\`account_access\` ON \`account_access\`.\`id\` = \`characters\`.\`account\`
|
||||
WHERE
|
||||
${where}
|
||||
AND (\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0 OR ? = 0)
|
||||
`, [character, this.armory.config.hideGameMasters ? 1 : 0]);
|
||||
|
||||
if ((rows as RowDataPacket[]).length === 0) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ const classFiles = {
|
|||
|
||||
export class IndexController {
|
||||
private armory: Armory;
|
||||
private charsetCache: { [key: string]: string };
|
||||
|
||||
public constructor(armory: Armory) {
|
||||
this.armory = armory;
|
||||
this.charsetCache = {};
|
||||
}
|
||||
|
||||
public async index(req: express.Request, res: express.Response): Promise<void> {
|
||||
|
|
@ -53,18 +55,22 @@ export class IndexController {
|
|||
}
|
||||
|
||||
const db = this.armory.getCharactersDb(realm.name);
|
||||
let [rows, fields] = await db.query(`
|
||||
SELECT CCSA.character_set_name FROM information_schema.\`TABLES\` T,
|
||||
information_schema.\`COLLATION_CHARACTER_SET_APPLICABILITY\` CCSA
|
||||
WHERE CCSA.collation_name = T.table_collation
|
||||
AND T.table_schema = "${db.config.database}"
|
||||
AND T.table_name = "characters"
|
||||
`);
|
||||
const charSet = rows[0].character_set_name;
|
||||
|
||||
const ssp = new DataTablesSsp(req.query, db, "characters", "guid", [
|
||||
if (!(realm.name in this.charsetCache)) {
|
||||
let [rows, fields] = await db.query(`
|
||||
SELECT CCSA.character_set_name FROM information_schema.\`TABLES\` T,
|
||||
information_schema.\`COLLATION_CHARACTER_SET_APPLICABILITY\` CCSA
|
||||
WHERE CCSA.collation_name = T.table_collation
|
||||
AND T.table_schema = "${db.config.database}"
|
||||
AND T.table_name = "characters"
|
||||
`);
|
||||
this.charsetCache[realm.name] = rows[0].character_set_name;
|
||||
}
|
||||
const charSet = this.charsetCache[realm.name];
|
||||
|
||||
let ssp = new DataTablesSsp(req.query, db, "characters", "guid", [
|
||||
{ name: "name", collation: `${charSet}_general_ci` },
|
||||
{ name: "name", table: "guild" },
|
||||
{ table: "guild", name: "name" },
|
||||
{ name: "level" },
|
||||
{ name: "race", formatter: (race, row) => `${raceFiles[race]}_${row[6] === 0 ? "male" : "female"}` },
|
||||
{ name: "class", formatter: cls => classFiles[cls] },
|
||||
|
|
@ -76,6 +82,11 @@ export class IndexController {
|
|||
];
|
||||
ssp.extraDataColumns = ["`characters`.`gender`"];
|
||||
|
||||
if (this.armory.config.hideGameMasters) {
|
||||
ssp.joins.push({ table1: "characters", column1: "account", table2: "account_access", column2: "id", database2: realm.authDatabase, kind: "LEFT" });
|
||||
ssp = ssp.where(`\`account_access\`.\`id\` IS NULL OR \`account_access\`.\`RealmID\` NOT IN (-1, ${realm.realmId}) OR \`account_access\`.\`gmlevel\` = 0`);
|
||||
}
|
||||
|
||||
const result = await ssp
|
||||
.where("`deleteInfos_Account` IS NULL")
|
||||
.run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue