metamigo-api: fix linter errors

This commit is contained in:
Abel Luck 2023-03-13 16:40:04 +00:00
parent 594bc23583
commit f4a3031c5e
9 changed files with 181 additions and 108 deletions

View file

@ -1,6 +1,6 @@
import { Server } from "@hapi/hapi";
import { Service } from "@hapipal/schmervice";
import { promises as fs } from "fs";
import { promises as fs } from "node:fs";
import {
SignaldAPI,
SendResponsev1,
@ -185,7 +185,7 @@ export default class SignaldService extends Service {
await this.queueMessage(bot, message);
}
private async getAttachmentInfo(dataMessage: any) {
private async getAttachmentInfo(dataMessage: IncomingMessagev1) {
if (dataMessage.attachments?.length > 0) {
const attachmentInfo = dataMessage.attachments[0];
const buffer = await fs.readFile(attachmentInfo.storedFilename);
@ -193,14 +193,12 @@ export default class SignaldService extends Service {
const mimetype = attachmentInfo.contentType ?? "application/octet-stream";
const filename = attachmentInfo.customFilename ?? "unknown-filename";
return { attachment, mimetype, filename }
return { attachment, mimetype, filename };
}
return { attachment: null, mimetype: null, filename: null };
return { attachment: undefined, mimetype: undefined, filename: undefined };
}
private async queueMessage(bot: Bot, message: IncomingMessagev1) {
const { timestamp, account, data_message: dataMessage } = message;
if (!dataMessage?.body && !dataMessage?.attachments) {
@ -212,7 +210,9 @@ export default class SignaldService extends Service {
this.server.logger.debug({ message }, "invalid message received");
}
const { attachment, mimetype, filename } = await this.getAttachmentInfo(dataMessage);
const { attachment, mimetype, filename } = await this.getAttachmentInfo(
dataMessage
);
const receivedMessage = {
message,
@ -220,7 +220,7 @@ export default class SignaldService extends Service {
botPhoneNumber: bot.phoneNumber,
attachment,
mimetype,
filename
filename,
};
workerUtils.addJob("signald-message", receivedMessage, {