fix(geplante-nachrichten): add /api prefix to all API paths, fix subscribe room token, unmask empty bot credentials, add Einzelnachrichten tab
This commit is contained in:
@@ -521,7 +521,37 @@ async function sendVehicleEvent(vehicleId: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// ── One-Time Messages ─────────────────────────────────────────────────────────
|
||||
// ── Bot Room ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Finds or creates a 1:1 Nextcloud Talk room between the bot and the given user.
|
||||
* Returns the room token, null if bot isn't configured, or 'not_connected' if the
|
||||
* user hasn't linked their Nextcloud account.
|
||||
*/
|
||||
async function getOrCreateBotRoom(userId: string): Promise<string | null | 'not_connected'> {
|
||||
const creds = await getBotCredentials();
|
||||
if (!creds) return null;
|
||||
|
||||
// Look up the user's Nextcloud login name
|
||||
const userResult = await pool.query(
|
||||
'SELECT nextcloud_login_name FROM users WHERE id = $1',
|
||||
[userId],
|
||||
);
|
||||
const nextcloudLoginName = userResult.rows[0]?.nextcloud_login_name as string | null;
|
||||
if (!nextcloudLoginName) return 'not_connected';
|
||||
|
||||
// Use createRoom(type=1) — Nextcloud returns existing 1:1 if it already exists
|
||||
const { token } = await nextcloudService.createRoom(
|
||||
1,
|
||||
nextcloudLoginName,
|
||||
undefined,
|
||||
creds.username,
|
||||
creds.appPassword,
|
||||
);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface OneTimeMessage {
|
||||
id: string;
|
||||
@@ -598,6 +628,7 @@ const scheduledMessagesService = {
|
||||
getSubscriptionsForUser,
|
||||
buildAndSend,
|
||||
sendVehicleEvent,
|
||||
getOrCreateBotRoom,
|
||||
getOneTimeMessages,
|
||||
createOneTimeMessage,
|
||||
deleteOneTimeMessage,
|
||||
|
||||
Reference in New Issue
Block a user