Add more logging around attachment queueing
This commit is contained in:
parent
480e1808ba
commit
352818fd32
3 changed files with 59 additions and 4 deletions
|
@ -398,6 +398,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
shutdown: async () => {
|
shutdown: async () => {
|
||||||
|
window.log.info('background/shutdown');
|
||||||
// Stop background processing
|
// Stop background processing
|
||||||
window.Signal.AttachmentDownloads.stop();
|
window.Signal.AttachmentDownloads.stop();
|
||||||
if (idleDetector) {
|
if (idleDetector) {
|
||||||
|
|
|
@ -1722,12 +1722,19 @@
|
||||||
|
|
||||||
// Receive logic
|
// Receive logic
|
||||||
async queueAttachmentDownloads() {
|
async queueAttachmentDownloads() {
|
||||||
|
const attachmentsToQueue = this.get('attachments') || [];
|
||||||
const messageId = this.id;
|
const messageId = this.id;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let bodyPending;
|
let bodyPending;
|
||||||
|
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
attachmentsToQueue.length
|
||||||
|
} attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
|
|
||||||
const [longMessageAttachments, normalAttachments] = _.partition(
|
const [longMessageAttachments, normalAttachments] = _.partition(
|
||||||
this.get('attachments') || [],
|
attachmentsToQueue,
|
||||||
attachment =>
|
attachment =>
|
||||||
attachment.contentType === Whisper.Message.LONG_MESSAGE_CONTENT_TYPE
|
attachment.contentType === Whisper.Message.LONG_MESSAGE_CONTENT_TYPE
|
||||||
);
|
);
|
||||||
|
@ -1737,6 +1744,13 @@
|
||||||
`Received more than one long message attachment in message ${this.idForLogging()}`
|
`Received more than one long message attachment in message ${this.idForLogging()}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
longMessageAttachments.length
|
||||||
|
} long message attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
|
|
||||||
if (longMessageAttachments.length > 0) {
|
if (longMessageAttachments.length > 0) {
|
||||||
count += 1;
|
count += 1;
|
||||||
bodyPending = true;
|
bodyPending = true;
|
||||||
|
@ -1750,6 +1764,11 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
normalAttachments.length
|
||||||
|
} normal attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
const attachments = await Promise.all(
|
const attachments = await Promise.all(
|
||||||
normalAttachments.map((attachment, index) => {
|
normalAttachments.map((attachment, index) => {
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -1761,8 +1780,14 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const previewsToQueue = this.get('preview') || [];
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
previewsToQueue.length
|
||||||
|
} preview attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
const preview = await Promise.all(
|
const preview = await Promise.all(
|
||||||
(this.get('preview') || []).map(async (item, index) => {
|
previewsToQueue.map(async (item, index) => {
|
||||||
if (!item.image) {
|
if (!item.image) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -1779,8 +1804,14 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const contactsToQueue = this.get('contact') || [];
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
contactsToQueue.length
|
||||||
|
} contact attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
const contact = await Promise.all(
|
const contact = await Promise.all(
|
||||||
(this.get('contact') || []).map(async (item, index) => {
|
contactsToQueue.map(async (item, index) => {
|
||||||
if (!item.avatar || !item.avatar.avatar) {
|
if (!item.avatar || !item.avatar.avatar) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -1804,7 +1835,14 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
let quote = this.get('quote');
|
let quote = this.get('quote');
|
||||||
if (quote && quote.attachments && quote.attachments.length) {
|
const quoteAttachmentsToQueue =
|
||||||
|
quote && quote.attachments ? quote.attachments : [];
|
||||||
|
window.log.info(
|
||||||
|
`Queueing ${
|
||||||
|
quoteAttachmentsToQueue.length
|
||||||
|
} quote attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
|
if (quoteAttachmentsToQueue.length > 0) {
|
||||||
quote = {
|
quote = {
|
||||||
...quote,
|
...quote,
|
||||||
attachments: await Promise.all(
|
attachments: await Promise.all(
|
||||||
|
@ -1834,6 +1872,9 @@
|
||||||
|
|
||||||
let group = this.get('group_update');
|
let group = this.get('group_update');
|
||||||
if (group && group.avatar) {
|
if (group && group.avatar) {
|
||||||
|
window.log.info(
|
||||||
|
`Queueing group avatar download for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
count += 1;
|
count += 1;
|
||||||
group = {
|
group = {
|
||||||
...group,
|
...group,
|
||||||
|
@ -1847,6 +1888,9 @@
|
||||||
|
|
||||||
let sticker = this.get('sticker');
|
let sticker = this.get('sticker');
|
||||||
if (sticker) {
|
if (sticker) {
|
||||||
|
window.log.info(
|
||||||
|
`Queueing sticker download for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
count += 1;
|
count += 1;
|
||||||
const { packId, stickerId, packKey } = sticker;
|
const { packId, stickerId, packKey } = sticker;
|
||||||
|
|
||||||
|
@ -1891,6 +1935,10 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.log.info(
|
||||||
|
`Queued ${count} total attachment downloads for message ${this.idForLogging()}`
|
||||||
|
);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
this.set({
|
this.set({
|
||||||
bodyPending,
|
bodyPending,
|
||||||
|
|
|
@ -57,6 +57,7 @@ async function start(options = {}) {
|
||||||
throw new Error('attachment_downloads/start: logger must be provided!');
|
throw new Error('attachment_downloads/start: logger must be provided!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('attachment_downloads/start: enabling');
|
||||||
enabled = true;
|
enabled = true;
|
||||||
await resetAttachmentDownloadPending();
|
await resetAttachmentDownloadPending();
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ async function start(options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stop() {
|
async function stop() {
|
||||||
|
logger.info('attachment_downloads/stop: disabling');
|
||||||
enabled = false;
|
enabled = false;
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
@ -121,6 +123,7 @@ async function _tick() {
|
||||||
|
|
||||||
async function _maybeStartJob() {
|
async function _maybeStartJob() {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
|
logger.info('attachment_downloads/_maybeStartJob: not enabled, returning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +169,8 @@ async function _runJob(job) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info(`attachment_downloads/_runJob for job id ${id}`);
|
||||||
|
|
||||||
const found =
|
const found =
|
||||||
MessageController.getById(messageId) ||
|
MessageController.getById(messageId) ||
|
||||||
(await getMessageById(messageId, {
|
(await getMessageById(messageId, {
|
||||||
|
@ -261,6 +266,7 @@ async function _runJob(job) {
|
||||||
|
|
||||||
async function _finishJob(message, id) {
|
async function _finishJob(message, id) {
|
||||||
if (message) {
|
if (message) {
|
||||||
|
logger.info(`attachment_downloads/_finishJob for job id: ${id}`);
|
||||||
await saveMessage(message.attributes, {
|
await saveMessage(message.attributes, {
|
||||||
Message: Whisper.Message,
|
Message: Whisper.Message,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue