Import log instead of using it off of window

This commit is contained in:
Josh Perez 2021-09-17 14:27:53 -04:00 committed by GitHub
parent 8eb0dd3116
commit 65ddf0a9e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 3654 additions and 3433 deletions

View file

@ -92,6 +92,7 @@ import { getProfile } from '../util/getProfile';
import { SEALED_SENDER } from '../types/SealedSender';
import { getAvatarData } from '../util/getAvatarData';
import { createIdenticon } from '../util/createIdenticon';
import * as log from '../logging/log';
// TODO: remove once we move away from ArrayBuffers
const FIXMEU8 = Uint8Array;
@ -399,7 +400,7 @@ export class ConversationModel extends window.Backbone
const bothFalsey = Boolean(current) === false && Boolean(seconds) === false;
if (current === seconds || bothFalsey) {
window.log.warn(
log.warn(
`updateExpirationTimerInGroupV2/${idLog}: Requested timer ${seconds} is unchanged from existing ${current}.`
);
return undefined;
@ -420,7 +421,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (!this.isMemberPending(conversationId)) {
window.log.warn(
log.warn(
`promotePendingMember/${idLog}: ${conversationId} is not a pending member of group. Returning early.`
);
return undefined;
@ -464,7 +465,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (!this.isMemberRequestingToJoin(conversationId)) {
window.log.warn(
log.warn(
`approvePendingApprovalRequest/${idLog}: ${conversationId} is not requesting to join the group. Returning early.`
);
return undefined;
@ -499,7 +500,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (!this.isMemberRequestingToJoin(conversationId)) {
window.log.warn(
log.warn(
`denyPendingApprovalRequest/${idLog}: ${conversationId} is not requesting to join the group. Returning early.`
);
return undefined;
@ -544,9 +545,7 @@ export class ConversationModel extends window.Backbone
this.get('announcementsOnly') &&
!toRequest.get('capabilities')?.announcementGroup
) {
window.log.warn(
`addPendingApprovalRequest/${idLog}: member needs to upgrade.`
);
log.warn(`addPendingApprovalRequest/${idLog}: member needs to upgrade.`);
return undefined;
}
@ -569,7 +568,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (this.isMemberAwaitingApproval(conversationId)) {
window.log.warn(
log.warn(
`addPendingApprovalRequest/${idLog}: ${conversationId} already in pending approval.`
);
return undefined;
@ -598,9 +597,7 @@ export class ConversationModel extends window.Backbone
this.get('announcementsOnly') &&
!toRequest.get('capabilities')?.announcementGroup
) {
window.log.warn(
`addMember/${idLog}: ${conversationId} needs to upgrade.`
);
log.warn(`addMember/${idLog}: ${conversationId} needs to upgrade.`);
return undefined;
}
@ -623,9 +620,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (this.isMember(conversationId)) {
window.log.warn(
`addMember/${idLog}: ${conversationId} already a member.`
);
log.warn(`addMember/${idLog}: ${conversationId} already a member.`);
return undefined;
}
@ -647,7 +642,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (!this.isMemberPending(conversationId)) {
window.log.warn(
log.warn(
`removePendingMember/${idLog}: ${conversationId} is not a pending member of group. Returning early.`
);
return undefined;
@ -655,7 +650,7 @@ export class ConversationModel extends window.Backbone
const pendingMember = window.ConversationController.get(conversationId);
if (!pendingMember) {
window.log.warn(
log.warn(
`removePendingMember/${idLog}: No conversation found for conversation ${conversationId}`
);
return undefined;
@ -663,7 +658,7 @@ export class ConversationModel extends window.Backbone
const uuid = pendingMember.get('uuid');
if (!uuid) {
window.log.warn(
log.warn(
`removePendingMember/${idLog}: Missing uuid for conversation ${pendingMember.idForLogging()}`
);
return undefined;
@ -691,7 +686,7 @@ export class ConversationModel extends window.Backbone
// button press and when we get here. It's especially important to check here
// in conflict/retry cases.
if (!this.isMember(conversationId)) {
window.log.warn(
log.warn(
`removeMember/${idLog}: ${conversationId} is not a pending member of group. Returning early.`
);
return undefined;
@ -727,7 +722,7 @@ export class ConversationModel extends window.Backbone
const idLog = this.idForLogging();
if (!this.isMember(conversationId)) {
window.log.warn(
log.warn(
`toggleAdminChange/${idLog}: ${conversationId} is not a pending member of group. Returning early.`
);
return undefined;
@ -796,7 +791,7 @@ export class ConversationModel extends window.Backbone
}
setUnregistered(): void {
window.log.info(`Conversation ${this.idForLogging()} is now unregistered`);
log.info(`Conversation ${this.idForLogging()} is now unregistered`);
this.set({
discoveredUnregisteredAt: Date.now(),
});
@ -808,9 +803,7 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info(
`Conversation ${this.idForLogging()} is registered once again`
);
log.info(`Conversation ${this.idForLogging()} is registered once again`);
this.set({
discoveredUnregisteredAt: undefined,
});
@ -900,7 +893,7 @@ export class ConversationModel extends window.Backbone
}
enableProfileSharing({ viaStorageServiceSync = false } = {}): void {
window.log.info(
log.info(
`enableProfileSharing: ${this.idForLogging()} storage? ${viaStorageServiceSync}`
);
const before = this.get('profileSharing');
@ -915,7 +908,7 @@ export class ConversationModel extends window.Backbone
}
disableProfileSharing({ viaStorageServiceSync = false } = {}): void {
window.log.info(
log.info(
`disableProfileSharing: ${this.idForLogging()} storage? ${viaStorageServiceSync}`
);
const before = this.get('profileSharing');
@ -1041,7 +1034,7 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info(
log.info(
`Fetching uuid for a sms-only conversation ${this.idForLogging()}`
);
@ -1060,7 +1053,7 @@ export class ConversationModel extends window.Backbone
this.isFetchingUUID = false;
this.trigger('change', this);
window.log.info(
log.info(
`Done fetching uuid for a sms-only conversation ${this.idForLogging()}`
);
}
@ -1110,7 +1103,7 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info(`Repairing GroupV2 conversation ${this.idForLogging()}`);
log.info(`Repairing GroupV2 conversation ${this.idForLogging()}`);
const { masterKey, secretParams, publicParams } = data;
this.set({ masterKey, secretParams, publicParams, groupVersion: 2 });
@ -1325,7 +1318,7 @@ export class ConversationModel extends window.Backbone
}
const { stack } = new Error('for stack');
window.log.warn(
log.warn(
`Conversation.format()/${this.idForLogging()} reentrant call! ${stack}`
);
@ -1701,11 +1694,11 @@ export class ConversationModel extends window.Backbone
isGroupV2(this.attributes) &&
this.isMember(ourConversationId)
) {
window.log.info(
log.info(
'applyMessageRequestResponse/accept: Already a member of v2 group'
);
} else {
window.log.error(
log.error(
'applyMessageRequestResponse/accept: Neither member nor pending member of v2 group'
);
}
@ -1822,7 +1815,7 @@ export class ConversationModel extends window.Backbone
if (errorDetails !== ALREADY_REQUESTED_TO_JOIN) {
throw error;
} else {
window.log.info(
log.info(
'joinGroupV2ViaLink: Got 400, but server is telling us we have already requested to join. Forcing that local state'
);
this.set({
@ -1938,7 +1931,7 @@ export class ConversationModel extends window.Backbone
createGroupChange: () => this.removeMember(ourConversationId),
});
} else {
window.log.error(
log.error(
'leaveGroupV2: We were neither a member nor a pending member of the group'
);
}
@ -1950,7 +1943,7 @@ export class ConversationModel extends window.Backbone
}
if (!this.isMember(conversationId)) {
window.log.error(
log.error(
`toggleAdmin: Member ${conversationId} is not a member of the group`
);
return;
@ -2036,7 +2029,7 @@ export class ConversationModel extends window.Backbone
extraConversationsForSend: [conversationId],
});
} else {
window.log.error(
log.error(
`removeFromGroupV2: Member ${conversationId} is neither a member nor a pending member of the group`
);
}
@ -2055,7 +2048,7 @@ export class ConversationModel extends window.Backbone
const groupId = this.getGroupIdBuffer();
if (window.ConversationController.areWePrimaryDevice()) {
window.log.warn(
log.warn(
'syncMessageRequestResponse: We are primary device; not sending message request sync'
);
return;
@ -2209,9 +2202,7 @@ export class ConversationModel extends window.Backbone
verified
);
} else {
window.log.warn(
`_setVerified(${this.id}): no uuid to update protocol storage`
);
log.warn(`_setVerified(${this.id}): no uuid to update protocol storage`);
}
this.set({ verified });
@ -2262,7 +2253,7 @@ export class ConversationModel extends window.Backbone
}
if (window.ConversationController.areWePrimaryDevice()) {
window.log.warn(
log.warn(
'sendVerifySyncMessage: We are primary device; not sending sync'
);
return;
@ -2366,7 +2357,7 @@ export class ConversationModel extends window.Backbone
const uuid = this.get('uuid');
if (!uuid) {
window.log.warn(`setApproved(${this.id}): no uuid, ignoring`);
log.warn(`setApproved(${this.id}): no uuid, ignoring`);
return;
}
@ -2475,10 +2466,9 @@ export class ConversationModel extends window.Backbone
receivedAt: number;
receivedAtCounter: number;
}): Promise<void> {
window.log.info(
`addChatSessionRefreshed: adding for ${this.idForLogging()}`,
{ receivedAt }
);
log.info(`addChatSessionRefreshed: adding for ${this.idForLogging()}`, {
receivedAt,
});
const message = ({
conversationId: this.id,
@ -2514,7 +2504,7 @@ export class ConversationModel extends window.Backbone
senderUuid: string;
sentAt: number;
}): Promise<void> {
window.log.info(`addDeliveryIssue: adding for ${this.idForLogging()}`, {
log.info(`addDeliveryIssue: adding for ${this.idForLogging()}`, {
sentAt,
senderUuid,
});
@ -2546,7 +2536,7 @@ export class ConversationModel extends window.Backbone
}
async addKeyChange(keyChangedId: UUID): Promise<void> {
window.log.info(
log.info(
'adding key change advisory for',
this.idForLogging(),
keyChangedId.toString(),
@ -2596,15 +2586,13 @@ export class ConversationModel extends window.Backbone
window._.defaults(options, { local: true });
if (isMe(this.attributes)) {
window.log.info(
'refusing to add verified change advisory for our own number'
);
log.info('refusing to add verified change advisory for our own number');
return;
}
const lastMessage = this.get('timestamp') || Date.now();
window.log.info(
log.info(
'adding verified change advisory for',
this.idForLogging(),
verifiedChangeId,
@ -2851,7 +2839,7 @@ export class ConversationModel extends window.Backbone
}
async addChangeNumberNotification(): Promise<void> {
window.log.info(
log.info(
`Conversation ${this.idForLogging()}: adding change number notification`
);
@ -2981,9 +2969,7 @@ export class ConversationModel extends window.Backbone
const waitTime = startedAt - queuedAt;
if (waitTime > JOB_REPORTING_THRESHOLD_MS) {
window.log.info(
`Conversation job ${name} was blocked for ${waitTime}ms`
);
log.info(`Conversation job ${name} was blocked for ${waitTime}ms`);
}
try {
@ -2992,7 +2978,7 @@ export class ConversationModel extends window.Backbone
const duration = Date.now() - startedAt;
if (duration > JOB_REPORTING_THRESHOLD_MS) {
window.log.info(`Conversation job ${name} took ${duration}ms`);
log.info(`Conversation job ${name} took ${duration}ms`);
}
}
});
@ -3241,7 +3227,7 @@ export class ConversationModel extends window.Backbone
const packData = Stickers.getStickerPack(packId);
const stickerData = Stickers.getSticker(packId, stickerId);
if (!stickerData || !packData) {
window.log.warn(
log.warn(
`Attempted to send nonexistent (${packId}, ${stickerId}) sticker!`
);
return;
@ -3262,9 +3248,7 @@ export class ConversationModel extends window.Backbone
if (sniffedMimeType) {
contentType = sniffedMimeType;
} else {
window.log.warn(
'Unable to sniff sticker MIME type; falling back to WebP'
);
log.warn('Unable to sniff sticker MIME type; falling back to WebP');
contentType = IMAGE_WEBP;
}
@ -3305,7 +3289,7 @@ export class ConversationModel extends window.Backbone
const destination = this.getSendTarget()!;
await this.queueJob('sendDeleteForEveryone', async () => {
window.log.info(
log.info(
'Sending deleteForEveryone to conversation',
this.idForLogging(),
'with timestamp',
@ -3395,7 +3379,7 @@ export class ConversationModel extends window.Backbone
return result;
}).catch(error => {
window.log.error(
log.error(
'Error sending deleteForEveryone',
deleteModel,
targetTimestamp,
@ -3434,7 +3418,7 @@ export class ConversationModel extends window.Backbone
const destination = this.getSendTarget()!;
return this.queueJob('sendReactionMessage', async () => {
window.log.info(
log.info(
'Sending reaction to conversation',
this.idForLogging(),
'with timestamp',
@ -3570,17 +3554,17 @@ export class ConversationModel extends window.Backbone
const id = this.get('id');
const recipients = this.getRecipients();
if (!this.get('profileSharing')) {
window.log.error(
log.error(
'Attempted to send profileKeyUpdate to conversation without profileSharing enabled',
id,
recipients
);
return;
}
window.log.info('Sending profileKeyUpdate to conversation', id, recipients);
log.info('Sending profileKeyUpdate to conversation', id, recipients);
const profileKey = await ourProfileKeyService.get();
if (!profileKey) {
window.log.error(
log.error(
'Attempted to send profileKeyUpdate but our profile key was not found'
);
return;
@ -3640,7 +3624,7 @@ export class ConversationModel extends window.Backbone
const expireTimer = this.get('expireTimer');
window.log.info(
log.info(
'Sending message to conversation',
this.idForLogging(),
'with timestamp',
@ -3709,7 +3693,7 @@ export class ConversationModel extends window.Backbone
await normalMessageSendJobQueue.add(
{ messageId: message.id, conversationId: this.id },
async jobToInsert => {
window.log.info(
log.info(
`enqueueMessageForSend: saving message ${message.id} and job ${jobToInsert.id}`
);
await window.Signal.Data.saveMessage(message.attributes, {
@ -3721,7 +3705,7 @@ export class ConversationModel extends window.Backbone
const dbDuration = Date.now() - dbStart;
if (dbDuration > SEND_REPORTING_THRESHOLD_MS) {
window.log.info(
log.info(
`ConversationModel(${this.idForLogging()}.sendMessage(${now}): ` +
`db save took ${dbDuration}ms`
);
@ -3755,7 +3739,7 @@ export class ConversationModel extends window.Backbone
const renderDuration = Date.now() - renderStart;
if (renderDuration > SEND_REPORTING_THRESHOLD_MS) {
window.log.info(
log.info(
`ConversationModel(${this.idForLogging()}.sendMessage(${now}): ` +
`render save took ${renderDuration}ms`
);
@ -3902,7 +3886,7 @@ export class ConversationModel extends window.Backbone
window.Signal.Groups.generateGroupInviteLinkPassword()
);
window.log.info('refreshGroupLink for conversation', this.idForLogging());
log.info('refreshGroupLink for conversation', this.idForLogging());
await this.modifyGroupV2({
name: 'updateInviteLinkPassword',
@ -3929,11 +3913,7 @@ export class ConversationModel extends window.Backbone
window.Signal.Groups.generateGroupInviteLinkPassword()
);
window.log.info(
'toggleGroupLink for conversation',
this.idForLogging(),
value
);
log.info('toggleGroupLink for conversation', this.idForLogging(), value);
const ACCESS_ENUM = Proto.AccessControl.AccessRequired;
const addFromInviteLink = value
@ -4108,7 +4088,7 @@ export class ConversationModel extends window.Backbone
return null;
}
window.log.info("Update conversation 'expireTimer'", {
log.info("Update conversation 'expireTimer'", {
id: this.idForLogging(),
expireTimer,
source,
@ -4223,7 +4203,7 @@ export class ConversationModel extends window.Backbone
const timestamp = Date.now();
if (this.hasAddedHistoryDisclaimer) {
window.log.warn(
log.warn(
`addMessageHistoryDisclaimer/${this.idForLogging()}: Refusing to add another this session`
);
return;
@ -4489,7 +4469,7 @@ export class ConversationModel extends window.Backbone
): Promise<void> {
// profileKey is a string so we can compare it directly
if (this.get('profileKey') !== profileKey) {
window.log.info(
log.info(
`Setting sealedSender to UNKNOWN for conversation ${this.idForLogging()}`
);
this.set({
@ -4780,18 +4760,14 @@ export class ConversationModel extends window.Backbone
// [X] dontNotifyForMentionsIfMuted
captureChange(logMessage: string): void {
if (!window.Signal.RemoteConfig.isEnabled('desktop.storageWrite3')) {
window.log.info(
log.info(
'conversation.captureChange: Returning early; desktop.storageWrite3 is falsey'
);
return;
}
window.log.info(
'storageService[captureChange]',
logMessage,
this.idForLogging()
);
log.info('storageService[captureChange]', logMessage, this.idForLogging());
this.set({ needsStorageServiceSync: true });
this.queueJob('captureChange', async () => {
@ -5003,7 +4979,7 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info('pinning', this.idForLogging());
log.info('pinning', this.idForLogging());
const pinnedConversationIds = new Set(
window.storage.get('pinnedConversationIds', new Array<string>())
);
@ -5025,7 +5001,7 @@ export class ConversationModel extends window.Backbone
return;
}
window.log.info('un-pinning', this.idForLogging());
log.info('un-pinning', this.idForLogging());
const pinnedConversationIds = new Set(
window.storage.get('pinnedConversationIds', new Array<string>())

View file

@ -113,6 +113,7 @@ import * as LinkPreview from '../types/LinkPreview';
import { SignalService as Proto } from '../protobuf';
import { normalMessageSendJobQueue } from '../jobs/normalMessageSendJobQueue';
import type { PreviewType as OutgoingPreviewType } from '../textsecure/SendMessage';
import * as log from '../logging/log';
/* eslint-disable camelcase */
/* eslint-disable more/no-then */
@ -198,7 +199,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
this.set(
TypedMessage.initializeSchemaVersion({
message: attributes,
logger: window.log,
logger: log,
})
);
}
@ -630,7 +631,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
const { emoji } = sticker || {};
if (!emoji) {
window.log.warn('Unable to get emoji for sticker');
log.warn('Unable to get emoji for sticker');
}
return {
text: window.i18n('message--getNotificationText--stickers'),
@ -651,9 +652,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
};
}
window.log.error(
"This call history message doesn't have valid call history"
);
log.error("This call history message doesn't have valid call history");
}
if (isExpirationTimerUpdate(attributes)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@ -756,7 +755,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const required = ['conversationId', 'received_at', 'sent_at'];
const missing = _.filter(required, attr => !attributes[attr]);
if (missing.length) {
window.log.warn(`Message missing attributes: ${missing}`);
log.warn(`Message missing attributes: ${missing}`);
}
}
@ -846,13 +845,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const { fromSync } = options || {};
if (!this.isValidTapToView()) {
window.log.warn(
log.warn(
`markViewOnceMessageViewed: Message ${this.idForLogging()} is not a valid tap to view message!`
);
return;
}
if (this.isErased()) {
window.log.warn(
log.warn(
`markViewOnceMessageViewed: Message ${this.idForLogging()} is already erased!`
);
return;
@ -879,7 +878,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
});
if (window.ConversationController.areWePrimaryDevice()) {
window.log.warn(
log.warn(
'markViewOnceMessageViewed: We are primary device; not sending view once open sync'
);
return;
@ -901,9 +900,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const logId = this.idForLogging();
const quote = this.get('quote');
if (!quote) {
window.log.warn(
`doubleCheckMissingQuoteReference/${logId}: Missing quote!`
);
log.warn(`doubleCheckMissingQuoteReference/${logId}: Missing quote!`);
return;
}
@ -913,7 +910,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// Is the quote really without a reference? Check with our in memory store
// first to make sure it's not there.
if (referencedMessageNotFound && contact) {
window.log.info(
log.info(
`doubleCheckMissingQuoteReference/${logId}: Verifying reference to ${sentAt}`
);
const inMemoryMessages = window.MessageController.filterBySentAt(
@ -923,7 +920,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
isQuoteAMatch(message, this.get('conversationId'), quote)
);
if (!matchingMessage) {
window.log.info(
log.info(
`doubleCheckMissingQuoteReference/${logId}: No match for ${sentAt}.`
);
@ -937,7 +934,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
},
});
window.log.info(
log.info(
`doubleCheckMissingQuoteReference/${logId}: Found match for ${sentAt}, updating.`
);
@ -960,7 +957,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
additionalProperties = {},
shouldPersist = true
): Promise<void> {
window.log.info(`Erasing data for message ${this.idForLogging()}`);
log.info(`Erasing data for message ${this.idForLogging()}`);
// Note: There are cases where we want to re-erase a given message. For example, when
// a viewed (or outgoing) View-Once message is deleted for everyone.
@ -968,7 +965,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
try {
await this.deleteData();
} catch (error) {
window.log.error(
log.error(
`Error erasing data for message ${this.idForLogging()}:`,
error && error.stack ? error.stack : error
);
@ -1075,7 +1072,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return this.get('source');
}
if (!isOutgoing(this.attributes)) {
window.log.warn(
log.warn(
'Message.getSource: Called for non-incoming/non-outoing message'
);
}
@ -1090,7 +1087,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return sourceDevice;
}
if (!isOutgoing(this.attributes)) {
window.log.warn(
log.warn(
'Message.getSourceDevice: Called for non-incoming/non-outoing message'
);
}
@ -1103,7 +1100,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return this.get('sourceUuid');
}
if (!isOutgoing(this.attributes)) {
window.log.warn(
log.warn(
'Message.getSourceUuid: Called for non-incoming/non-outoing message'
);
}
@ -1145,7 +1142,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
errors.forEach(e => {
window.log.error(
log.error(
'Message.saveErrors:',
e && e.reason ? e.reason : null,
e && e.stack ? e.stack : e
@ -1207,7 +1204,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const retryOptions = this.get('retryOptions');
if (retryOptions) {
if (!window.textsecure.messaging) {
window.log.error('retrySend: Cannot retry since we are offline!');
log.error('retrySend: Cannot retry since we are offline!');
return;
}
this.unset('errors');
@ -1611,7 +1608,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
});
if (window.ConversationController.areWePrimaryDevice()) {
window.log.warn(
log.warn(
'sendSyncMessage: We are primary device; not sending sync message'
);
this.set({ dataMessage: undefined });
@ -1832,7 +1829,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
let count = 0;
let bodyPending;
window.log.info(
log.info(
`Queueing ${
attachmentsToQueue.length
} attachment downloads for message ${this.idForLogging()}`
@ -1846,12 +1843,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
if (longMessageAttachments.length > 1) {
window.log.error(
log.error(
`Received more than one long message attachment in message ${this.idForLogging()}`
);
}
window.log.info(
log.info(
`Queueing ${
longMessageAttachments.length
} long message attachment downloads for message ${this.idForLogging()}`
@ -1867,7 +1864,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
});
}
window.log.info(
log.info(
`Queueing ${
normalAttachments.length
} normal attachment downloads for message ${this.idForLogging()}`
@ -1879,7 +1876,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
// We've already downloaded this!
if (attachment.path) {
window.log.info(
log.info(
`Normal attachment already downloaded for message ${this.idForLogging()}`
);
return attachment;
@ -1896,7 +1893,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
const previewsToQueue = this.get('preview') || [];
window.log.info(
log.info(
`Queueing ${
previewsToQueue.length
} preview attachment downloads for message ${this.idForLogging()}`
@ -1908,7 +1905,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
// We've already downloaded this!
if (item.image.path) {
window.log.info(
log.info(
`Preview attachment already downloaded for message ${this.idForLogging()}`
);
return item;
@ -1927,7 +1924,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
const contactsToQueue = this.get('contact') || [];
window.log.info(
log.info(
`Queueing ${
contactsToQueue.length
} contact attachment downloads for message ${this.idForLogging()}`
@ -1939,7 +1936,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
// We've already downloaded this!
if (item.avatar.avatar.path) {
window.log.info(
log.info(
`Contact attachment already downloaded for message ${this.idForLogging()}`
);
return item;
@ -1964,7 +1961,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
let quote = this.get('quote')!;
const quoteAttachmentsToQueue =
quote && quote.attachments ? quote.attachments : [];
window.log.info(
log.info(
`Queueing ${
quoteAttachmentsToQueue.length
} quote attachment downloads for message ${this.idForLogging()}`
@ -1979,7 +1976,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
// We've already downloaded this!
if (item.thumbnail.path) {
window.log.info(
log.info(
`Quote attachment already downloaded for message ${this.idForLogging()}`
);
return item;
@ -2002,13 +1999,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
let sticker = this.get('sticker')!;
if (sticker && sticker.data && sticker.data.path) {
window.log.info(
log.info(
`Sticker attachment already downloaded for message ${this.idForLogging()}`
);
} else if (sticker) {
window.log.info(
`Queueing sticker download for message ${this.idForLogging()}`
);
log.info(`Queueing sticker download for message ${this.idForLogging()}`);
count += 1;
const { packId, stickerId, packKey } = sticker;
@ -2026,7 +2021,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
contentType: IMAGE_WEBP,
};
} catch (error) {
window.log.error(
log.error(
`Problem copying sticker (${packId}, ${stickerId}) to attachments:`,
error && error.stack ? error.stack : error
);
@ -2059,7 +2054,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
};
}
window.log.info(
log.info(
`Queued ${count} total attachment downloads for message ${this.idForLogging()}`
);
@ -2111,9 +2106,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
}
window.log.info(
'markAttachmentAsCorrupted: marking an attachment as corrupted'
);
log.info('markAttachmentAsCorrupted: marking an attachment as corrupted');
this.set({
attachments: newAttachments,
@ -2171,7 +2164,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
if (matchingMessage) {
queryMessage = matchingMessage;
} else {
window.log.info('copyFromQuotedMessage: db lookup needed', id);
log.info('copyFromQuotedMessage: db lookup needed', id);
const collection = await window.Signal.Data.getMessagesBySentAt(id, {
MessageCollection: window.Whisper.MessageCollection,
});
@ -2252,7 +2245,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
await window.Signal.Data.saveMessage(upgradedMessage);
}
} catch (error) {
window.log.error(
log.error(
'Problem upgrading message quoted message from database',
Errors.toLogFormat(error)
);
@ -2322,7 +2315,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const conversation = window.ConversationController.get(conversationId)!;
return conversation.queueJob('handleDataMessage', async () => {
window.log.info(
log.info(
`Starting handleDataMessage for message ${message.idForLogging()} in conversation ${conversation.idForLogging()}`
);
@ -2331,12 +2324,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
this.getSenderIdentifier()
);
if (inMemoryMessage) {
window.log.info(
'handleDataMessage: cache hit',
this.getSenderIdentifier()
);
log.info('handleDataMessage: cache hit', this.getSenderIdentifier());
} else {
window.log.info(
log.info(
'handleDataMessage: duplicate check db lookup needed',
this.getSenderIdentifier()
);
@ -2349,13 +2339,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const isUpdate = Boolean(data && data.isRecipientUpdate);
if (existingMessage && type === 'incoming') {
window.log.warn('Received duplicate message', this.idForLogging());
log.warn('Received duplicate message', this.idForLogging());
confirm();
return;
}
if (type === 'outgoing') {
if (isUpdate && existingMessage) {
window.log.info(
log.info(
`handleDataMessage: Updating message ${message.idForLogging()} with received transcript`
);
@ -2431,7 +2421,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return;
}
if (isUpdate) {
window.log.warn(
log.warn(
`handleDataMessage: Received update transcript, but no existing entry for message ${message.idForLogging()}. Dropping.`
);
@ -2439,7 +2429,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return;
}
if (existingMessage) {
window.log.warn(
log.warn(
`handleDataMessage: Received duplicate transcript for message ${message.idForLogging()}, but it was not an update transcript. Dropping.`
);
@ -2494,7 +2484,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
});
} catch (error) {
const errorText = error && error.stack ? error.stack : error;
window.log.error(
log.error(
`handleDataMessage: Failed to process group update for ${conversation.idForLogging()} as part of message ${message.idForLogging()}: ${errorText}`
);
throw error;
@ -2525,7 +2515,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
!conversation.hasMember(ourConversationId) ||
!conversation.hasMember(senderId))
) {
window.log.warn(
log.warn(
`Received message destined for group ${conversation.idForLogging()}, which we or the sender are not a part of. Dropping.`
);
confirm();
@ -2545,7 +2535,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
conversation.get('members') &&
(conversation.get('left') || !conversation.hasMember(ourConversationId))
) {
window.log.warn(
log.warn(
`Received message destined for group ${conversation.idForLogging()}, which we're not a part of. Dropping.`
);
confirm();
@ -2555,7 +2545,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// Because GroupV1 messages can now be multiplexed into GroupV2 conversations, we
// drop GroupV1 updates in GroupV2 groups.
if (isV1GroupUpdate && isGroupV2(conversation.attributes)) {
window.log.warn(
log.warn(
`Received GroupV1 update in GroupV2 conversation ${conversation.idForLogging()}. Dropping.`
);
confirm();
@ -2615,7 +2605,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
LinkPreview.isLinkSafeToPreview(item.url)
);
if (preview.length < incomingPreview.length) {
window.log.info(
log.info(
`${message.idForLogging()}: Eliminated ${
preview.length - incomingPreview.length
} previews with invalid urls'`
@ -2705,9 +2695,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
}
} catch (err) {
window.log.info(
'handleDataMessage: group avatar download failed'
);
log.info('handleDataMessage: group avatar download failed');
}
}
@ -2747,7 +2735,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
pendingGroupUpdate.avatarUpdated = true;
} else {
window.log.info(
log.info(
'handleDataMessage: Group avatar hash matched; not replacing group avatar'
);
}
@ -2766,7 +2754,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
pendingGroupUpdate.joined = [...e164s];
}
if (conversation.get('left')) {
window.log.warn('re-added to a left group');
log.warn('re-added to a left group');
attributes.left = false;
conversation.set({ addedBy: message.getContactId() });
}
@ -2779,7 +2767,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
if (!inGroup) {
const senderString = sender ? sender.idForLogging() : null;
window.log.info(
log.info(
`Got 'left' message from someone not in group: ${senderString}. Dropping.`
);
return;
@ -2806,7 +2794,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// message.set call and after GroupV1 processing to make sure all possible
// properties are set before we determine that a message is empty.
if (message.isEmpty()) {
window.log.info(
log.info(
`handleDataMessage: Dropping empty message ${message.idForLogging()} in conversation ${conversation.idForLogging()}`
);
confirm();
@ -2840,7 +2828,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const shouldLogExpireTimerChange =
isExpirationTimerUpdate(message.attributes) || expireTimer;
if (shouldLogExpireTimerChange) {
window.log.info("Update conversation 'expireTimer'", {
log.info("Update conversation 'expireTimer'", {
id: conversation.idForLogging(),
expireTimer,
source: 'handleDataMessage',
@ -2908,7 +2896,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
isTapToView(message.attributes) &&
!message.isValidTapToView()
) {
window.log.warn(
log.warn(
`Received tap to view message ${message.idForLogging()} with invalid data. Erasing contents.`
);
message.set({
@ -2949,7 +2937,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
) {
if (window.attachmentDownloadQueue) {
window.attachmentDownloadQueue.unshift(message);
window.log.info(
log.info(
'Adding to attachmentDownloadQueue',
message.get('sent_at')
);
@ -2961,14 +2949,14 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
const isFirstRun = true;
await this.modifyTargetMessage(conversation, isFirstRun);
window.log.info(
log.info(
'handleDataMessage: Batching save for',
message.get('sent_at')
);
this.saveAndNotify(conversation, confirm);
} catch (error) {
const errorForLog = error && error.stack ? error.stack : error;
window.log.error(
log.error(
'handleDataMessage',
message.idForLogging(),
'error:',
@ -2985,7 +2973,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
): Promise<void> {
await window.Signal.Util.saveNewMessageBatcher.add(this.attributes);
window.log.info('Message saved', this.get('sent_at'));
log.info('Message saved', this.get('sent_at'));
conversation.trigger('newmessage', this);
@ -3057,7 +3045,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
) => {
const oldSendState = getOwn(result, destinationConversationId);
if (!oldSendState) {
window.log.warn(
log.warn(
`Got a receipt for a conversation (${destinationConversationId}), but we have no record of sending to them`
);
return result;
@ -3177,7 +3165,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
);
if (changed && !isFirstRun) {
window.log.info(
log.info(
`modifyTargetMessage/${this.idForLogging()}: Changes in second run; saving.`
);
await window.Signal.Data.saveMessage(this.attributes);
@ -3219,7 +3207,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
let oldReaction: ReactionAttributesType | undefined;
if (reaction.get('remove')) {
window.log.info('Removing reaction for message', messageId);
log.info('Removing reaction for message', messageId);
const newReactions = reactions.filter(
re =>
re.emoji !== reaction.get('emoji') ||
@ -3240,7 +3228,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
targetTimestamp: reaction.get('targetTimestamp'),
});
} else {
window.log.info('Adding reaction for message', messageId);
log.info('Adding reaction for message', messageId);
const newReactions = reactions.filter(
re => re.fromId !== reaction.get('fromId')
);
@ -3281,7 +3269,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
const newCount = (this.get('reactions') || []).length;
window.log.info(
log.info(
`Done processing reaction for message ${messageId}. Went from ${count} to ${newCount} reactions.`
);
@ -3296,7 +3284,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
del: typeof window.WhatIsThis,
shouldPersist = true
): Promise<void> {
window.log.info('Handling DOE.', {
log.info('Handling DOE.', {
fromId: del.get('fromId'),
targetSentTimestamp: del.get('targetSentTimestamp'),
messageServerTimestamp: this.get('serverTimestamp'),