1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Add debugging for unsent to-device messages

This commit is contained in:
Richard van der Hoff
2022-10-19 11:22:38 +01:00
parent 17e16b9b1a
commit 620a8d9c7f

View File

@@ -48,14 +48,18 @@ export class ToDeviceMessageQueue {
public async queueBatch(batch: ToDeviceBatch): Promise<void> { public async queueBatch(batch: ToDeviceBatch): Promise<void> {
const batches: ToDeviceBatchWithTxnId[] = []; const batches: ToDeviceBatchWithTxnId[] = [];
for (let i = 0; i < batch.batch.length; i += MAX_BATCH_SIZE) { for (let i = 0; i < batch.batch.length; i += MAX_BATCH_SIZE) {
batches.push({ const batchWithTxnId = {
eventType: batch.eventType, eventType: batch.eventType,
batch: batch.batch.slice(i, i + MAX_BATCH_SIZE), batch: batch.batch.slice(i, i + MAX_BATCH_SIZE),
txnId: this.client.makeTxnId(), txnId: this.client.makeTxnId(),
}); };
batches.push(batchWithTxnId);
const recips = batchWithTxnId.batch.map((msg) => `${msg.userId}:${msg.deviceId}`);
logger.info(`Created batch of to-device messages with txn id ${batchWithTxnId.txnId} for ${recips}`);
} }
await this.client.store.saveToDeviceBatches(batches); await this.client.store.saveToDeviceBatches(batches);
logger.info(`Enqueued to-device messages with txn ids ${batches.map((batch) => batch.txnId)}`);
this.sendQueue(); this.sendQueue();
} }
@@ -118,7 +122,9 @@ export class ToDeviceMessageQueue {
contentMap[item.userId][item.deviceId] = item.payload; contentMap[item.userId][item.deviceId] = item.payload;
} }
logger.info(`Sending batch of ${batch.batch.length} to-device messages with ID ${batch.id}`); logger.info(
`Sending batch of ${batch.batch.length} to-device messages with ID ${batch.id} and txnId ${batch.txnId}`,
);
await this.client.sendToDevice(batch.eventType, contentMap, batch.txnId); await this.client.sendToDevice(batch.eventType, contentMap, batch.txnId);
} }