Add more logging around attachment queueing

This commit is contained in:
Ken Powers 2020-06-09 18:33:37 -04:00 committed by Scott Nonnenberg
parent 480e1808ba
commit 352818fd32
3 changed files with 59 additions and 4 deletions

View file

@ -57,6 +57,7 @@ async function start(options = {}) {
throw new Error('attachment_downloads/start: logger must be provided!');
}
logger.info('attachment_downloads/start: enabling');
enabled = true;
await resetAttachmentDownloadPending();
@ -64,6 +65,7 @@ async function start(options = {}) {
}
async function stop() {
logger.info('attachment_downloads/stop: disabling');
enabled = false;
if (timeout) {
clearTimeout(timeout);
@ -121,6 +123,7 @@ async function _tick() {
async function _maybeStartJob() {
if (!enabled) {
logger.info('attachment_downloads/_maybeStartJob: not enabled, returning');
return;
}
@ -166,6 +169,8 @@ async function _runJob(job) {
);
}
logger.info(`attachment_downloads/_runJob for job id ${id}`);
const found =
MessageController.getById(messageId) ||
(await getMessageById(messageId, {
@ -261,6 +266,7 @@ async function _runJob(job) {
async function _finishJob(message, id) {
if (message) {
logger.info(`attachment_downloads/_finishJob for job id: ${id}`);
await saveMessage(message.attributes, {
Message: Whisper.Message,
});