KI-AGENT: Matrix Service User automatisch in Räume aufnehmen

This commit is contained in:
2026-05-22 21:29:31 +02:00
parent 38ccdd058b
commit 45ca4f7327
2 changed files with 95 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ export function startMatrixPushWorker(server: FastifyInstance) {
let running = false
let stopped = false
let timer: ReturnType<typeof setTimeout> | undefined
let lastServiceJoinSyncAt = 0
const getTenantRecipients = async (tenantId: number) => {
const rows = await server.db
@@ -186,6 +187,18 @@ export function startMatrixPushWorker(server: FastifyInstance) {
running = true
try {
if (!lastServiceJoinSyncAt || Date.now() - lastServiceJoinSyncAt > 60_000) {
const joinResult = await matrix.syncServiceJoinedTenantRooms()
lastServiceJoinSyncAt = Date.now()
if (joinResult.failed) {
console.warn("Matrix-Push-Worker: Service-User konnte nicht alle Räume joinen", {
total: joinResult.total,
joined: joinResult.joined,
failed: joinResult.failed,
})
}
}
const initial = !since
const sync = await matrix.syncServiceRoomEvents(since, initial)
since = sync.nextBatch || since