Removed unsafe .get() calls from Mongoose documents

This commit is contained in:
Jonathan Barrow
2023-04-29 15:39:20 -04:00
parent cc62c8dad3
commit b9481892e0
2 changed files with 4 additions and 4 deletions

View File

@@ -100,13 +100,13 @@ async function NASCMiddleware(request: express.Request, response: express.Respon
});
if (device) {
if (device.get('access_level') < 0) {
if (device.access_level < 0) {
response.status(200).send(nascError('102').toString());
return;
}
if (pid) {
const linkedPIDs = device.get('linked_pids');
const linkedPIDs: number[] = device.linked_pids;
if (!linkedPIDs.includes(pid)) {
response.status(200).send(nascError('102').toString());

View File

@@ -192,7 +192,7 @@ PNIDSchema.method('updateMii', async function updateMii({ name, primary, data }:
});
PNIDSchema.method('generateMiiImages', async function generateMiiImages(): Promise<void> {
const miiData: string = this.get('mii.data');
const miiData: string = this.mii.data;
const mii: Mii = new Mii(Buffer.from(miiData, 'base64'));
const miiStudioUrl: string = mii.studioUrl({
type: 'face',
@@ -203,7 +203,7 @@ PNIDSchema.method('generateMiiImages', async function generateMiiImages(): Promi
const pngData: ImageData = await imagePixels(miiStudioNormalFaceImageData);
const tga: Buffer = TGA.createTgaBuffer(pngData.width, pngData.height, Uint8Array.from(pngData.data), false);
const userMiiKey: string = `mii/${this.get('pid')}`;
const userMiiKey: string = `mii/${this.pid}`;
await uploadCDNAsset('pn-cdn', `${userMiiKey}/standard.tga`, tga, 'public-read');
await uploadCDNAsset('pn-cdn', `${userMiiKey}/normal_face.png`, miiStudioNormalFaceImageData, 'public-read');