You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Add a message ID on each to-device message (#2938)
To make it easier to track down where to-device messages are getting lost, add a custom property to each one, and log its value. Synapse will also log this property.
This commit is contained in:
committed by
GitHub
parent
2c8eece5ca
commit
683e7fba4a
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { ToDeviceMessageId } from './@types/event';
|
||||
import { logger } from "./logger";
|
||||
import { MatrixError, MatrixClient } from "./matrix";
|
||||
import { IndexedToDeviceBatch, ToDeviceBatch, ToDeviceBatchWithTxnId, ToDevicePayload } from "./models/ToDeviceMessage";
|
||||
@@ -54,12 +55,15 @@ export class ToDeviceMessageQueue {
|
||||
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}`);
|
||||
const msgmap = batchWithTxnId.batch.map(
|
||||
(msg) => `${msg.userId}/${msg.deviceId} (msgid ${msg.payload[ToDeviceMessageId]})`,
|
||||
);
|
||||
logger.info(
|
||||
`Enqueuing batch of to-device messages. type=${batch.eventType} txnid=${batchWithTxnId.txnId}`, msgmap,
|
||||
);
|
||||
}
|
||||
|
||||
await this.client.store.saveToDeviceBatches(batches);
|
||||
logger.info(`Enqueued to-device messages with txn ids ${batches.map((batch) => batch.txnId)}`);
|
||||
this.sendQueue();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user