@badgerclaw/connect 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/room-config.json +3 -0
- package/src/matrix/monitor/auto-join.ts +19 -0
package/package.json
CHANGED
package/room-config.json
CHANGED
|
@@ -57,6 +57,25 @@ export function registerMatrixAutoJoin(params: {
|
|
|
57
57
|
// Ignore sync errors
|
|
58
58
|
}
|
|
59
59
|
})();
|
|
60
|
+
|
|
61
|
+
// When bot joins a new room, send a presence message to force Megolm session rotation
|
|
62
|
+
// This ensures all clients create a new session that includes the bot's device
|
|
63
|
+
client.on("room.join", async (roomId: string) => {
|
|
64
|
+
logVerbose(`badgerclaw: bot joined room ${roomId}, requesting key share`);
|
|
65
|
+
try {
|
|
66
|
+
// Send a dummy state event to signal our device presence
|
|
67
|
+
// This forces clients to include our device in the next Megolm session
|
|
68
|
+
await client.sendStateEvent(roomId, "m.room.member", await client.getUserId(), {
|
|
69
|
+
membership: "join",
|
|
70
|
+
displayname: "testbot",
|
|
71
|
+
}).catch(() => {});
|
|
72
|
+
|
|
73
|
+
// Also send a notice message to trigger session rotation
|
|
74
|
+
await client.sendNotice(roomId, "🦡 Bot connected to this room.").catch(() => {});
|
|
75
|
+
} catch (err) {
|
|
76
|
+
logVerbose(`badgerclaw: failed to send join notice in ${roomId}: ${err}`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
60
79
|
return;
|
|
61
80
|
}
|
|
62
81
|
|