-
-
Notifications
You must be signed in to change notification settings - Fork 649
Description
Describe the bug
I have an image bot that sends an image based on user input. I've noticed since updating to a recent matrix-js-sdk that whenever I send an event with the SDK, it logs a line that says EventTimelineSet.addLiveEvent: ignoring duplicate event $event_id, where $event_id is the event sent by the sdk.
To Reproduce
This is the simplified version of the code I am using with matrix-js-sdk 19.3.0 to reproduce the issue:
const sdk = require("matrix-js-sdk");
const matrixcs = require("matrix-js-sdk/lib/matrix");
const request = require('request');
matrixcs.request(request);
const log = require('loglevel');
const { logger} = require('matrix-js-sdk/lib/logger');
logger.setLevel(log.levels.INFO, false);
var myUserId = "@test:matrix.example.com";
var myAccessToken = "syt_token";
var matrixClient = sdk.createClient({
baseUrl: "https://matrix.example.com",
accessToken: myAccessToken,
userId: myUserId
});
matrixClient.on("Room.timeline", function(event, room, toStartOfTimeline) {
if (event.getType() === "m.room.message" && event.getContent().body.indexOf("!cot") === 0) {
matrixClient.sendImageMessage(room.roomId, "mxc://matrix.org/SZcQxxckvdxdzbIeiSurDEng", {"mimetype": "image/png"}, "cot.png", null);
}
});
matrixClient.startClient({initialSyncLimit: 0});
Once running, invite the account to a test room, then send !cot in the room with any other account.
Expected behavior
The "ignoring duplicate event" line shouldn't get logged.
Actual behavior
This is the output I get when sending !cot in the room and having the bot send the image:
$ node ./test.js
EventTimelineSet.addLiveEvent: ignoring duplicate event $-W_XVQn5UotOvWC3F7-gZfaWc5Boim3hI28labr-8ys
Desktop (please complete the following information):
- OS: Arch Linux
- Browser Firefox
- Version 103