feat(admin): centralize tool & module settings in Werkzeuge tab with per-tool permissions, DB-backed config, connection tests, and cog-button navigation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import httpClient from '../config/httpClient';
|
||||
import environment from '../config/environment';
|
||||
import toolConfigService from './toolConfig.service';
|
||||
import logger from '../utils/logger';
|
||||
|
||||
interface NextcloudLastMessage {
|
||||
@@ -77,7 +77,7 @@ function isValidServiceUrl(raw: string): boolean {
|
||||
}
|
||||
|
||||
async function initiateLoginFlow(): Promise<LoginFlowResult> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -145,7 +145,7 @@ interface NextcloudChatMessage {
|
||||
}
|
||||
|
||||
async function getAllConversations(loginName: string, appPassword: string): Promise<NextcloudConversation[]> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -206,7 +206,7 @@ interface GetMessagesOptions {
|
||||
}
|
||||
|
||||
async function getMessages(token: string, loginName: string, appPassword: string, options?: GetMessagesOptions): Promise<NextcloudChatMessage[]> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -294,7 +294,7 @@ async function getMessages(token: string, loginName: string, appPassword: string
|
||||
}
|
||||
|
||||
async function sendMessage(token: string, message: string, loginName: string, appPassword: string, replyTo?: number): Promise<void> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -331,7 +331,7 @@ async function sendMessage(token: string, message: string, loginName: string, ap
|
||||
}
|
||||
|
||||
async function markAsRead(token: string, loginName: string, appPassword: string): Promise<void> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -368,7 +368,7 @@ async function markAsRead(token: string, loginName: string, appPassword: string)
|
||||
}
|
||||
|
||||
async function getConversations(loginName: string, appPassword: string): Promise<ConversationsResult> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -441,7 +441,7 @@ async function uploadFileToTalk(
|
||||
loginName: string,
|
||||
appPassword: string,
|
||||
): Promise<void> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -503,7 +503,7 @@ async function downloadFile(
|
||||
loginName: string,
|
||||
appPassword: string,
|
||||
): Promise<any> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -544,7 +544,7 @@ async function getFilePreview(
|
||||
loginName: string,
|
||||
appPassword: string,
|
||||
): Promise<any> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -580,7 +580,7 @@ async function getFilePreview(
|
||||
}
|
||||
|
||||
async function searchUsers(query: string, loginName: string, appPassword: string): Promise<any[]> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -616,7 +616,7 @@ async function searchUsers(query: string, loginName: string, appPassword: string
|
||||
}
|
||||
|
||||
async function createRoom(roomType: number, invite: string, roomName: string | undefined, loginName: string, appPassword: string): Promise<{ token: string }> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -654,7 +654,7 @@ async function createRoom(roomType: number, invite: string, roomName: string | u
|
||||
}
|
||||
|
||||
async function addReaction(token: string, messageId: number, reaction: string, loginName: string, appPassword: string): Promise<void> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -691,7 +691,7 @@ async function addReaction(token: string, messageId: number, reaction: string, l
|
||||
}
|
||||
|
||||
async function removeReaction(token: string, messageId: number, reaction: string, loginName: string, appPassword: string): Promise<void> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -727,7 +727,7 @@ async function removeReaction(token: string, messageId: number, reaction: string
|
||||
}
|
||||
|
||||
async function getReactions(token: string, messageId: number, loginName: string, appPassword: string): Promise<Record<string, any>> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
@@ -763,7 +763,7 @@ async function getReactions(token: string, messageId: number, loginName: string,
|
||||
}
|
||||
|
||||
async function getPollDetails(token: string, pollId: number, loginName: string, appPassword: string): Promise<Record<string, any>> {
|
||||
const baseUrl = environment.nextcloudUrl;
|
||||
const { url: baseUrl } = await toolConfigService.getNextcloudConfig();
|
||||
if (!baseUrl || !isValidServiceUrl(baseUrl)) {
|
||||
throw new Error('NEXTCLOUD_URL is not configured or is not a valid service URL');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user