KI-AGENT: Erste Matrix-Backendintegration ergänzen
This commit is contained in:
30
backend/src/routes/communication.ts
Normal file
30
backend/src/routes/communication.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { FastifyInstance } from "fastify"
|
||||
import { matrixService } from "../modules/matrix.service"
|
||||
|
||||
export default async function communicationRoutes(server: FastifyInstance) {
|
||||
const matrix = matrixService(server)
|
||||
|
||||
server.get("/communication/matrix/status", async () => {
|
||||
return matrix.getStatus()
|
||||
})
|
||||
|
||||
server.get("/communication/matrix/me", async (req) => {
|
||||
const userId = req.user.user_id
|
||||
|
||||
return {
|
||||
matrixUserId: matrix.matrixUserIdForUser(userId),
|
||||
displayName: await matrix.getCurrentUserDisplayName(userId, req.user.tenant_id),
|
||||
}
|
||||
})
|
||||
|
||||
server.post("/communication/matrix/me/provision", async (req, reply) => {
|
||||
try {
|
||||
return await matrix.provisionCurrentUser(req.user.user_id, req.user.tenant_id)
|
||||
} catch (err: any) {
|
||||
req.log.error(err)
|
||||
return reply
|
||||
.code(err.statusCode || 500)
|
||||
.send({ error: err.message || "Matrix provisioning failed" })
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user