refactor: remove SSH/Docker configuration options from Jitsi settings and streamline related backend queries and mutations
This commit is contained in:
@@ -2,7 +2,6 @@ import { v } from "convex/values";
|
||||
import { mutation, query, action, internalMutation } from "./_generated/server";
|
||||
import { registrarAtividade } from "./logsAtividades";
|
||||
import { api, internal } from "./_generated/api";
|
||||
import { encryptSMTPPassword } from "./auth/utils";
|
||||
|
||||
/**
|
||||
* Obter configuração de Jitsi ativa
|
||||
@@ -33,44 +32,6 @@ export const obterConfigJitsi = query({
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Obter configuração completa de Jitsi (incluindo SSH, mas sem senha)
|
||||
*/
|
||||
export const obterConfigJitsiCompleta = query({
|
||||
args: {
|
||||
configId: v.id("configuracaoJitsi"),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const config = await ctx.db.get(args.configId);
|
||||
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
_id: config._id,
|
||||
domain: config.domain,
|
||||
appId: config.appId,
|
||||
roomPrefix: config.roomPrefix,
|
||||
useHttps: config.useHttps,
|
||||
acceptSelfSignedCert: config.acceptSelfSignedCert ?? false,
|
||||
ativo: config.ativo,
|
||||
testadoEm: config.testadoEm,
|
||||
atualizadoEm: config.atualizadoEm,
|
||||
configuradoEm: config.configuradoEm,
|
||||
// Configurações SSH (sem senha)
|
||||
sshHost: config.sshHost,
|
||||
sshPort: config.sshPort,
|
||||
sshUsername: config.sshUsername,
|
||||
sshPasswordHash: config.sshPasswordHash ? "********" : undefined, // Mascarar
|
||||
sshKeyPath: config.sshKeyPath,
|
||||
dockerComposePath: config.dockerComposePath,
|
||||
jitsiConfigPath: config.jitsiConfigPath,
|
||||
configuradoNoServidor: config.configuradoNoServidor ?? false,
|
||||
configuradoNoServidorEm: config.configuradoNoServidorEm,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Salvar configuração de Jitsi (apenas TI_MASTER)
|
||||
@@ -83,14 +44,6 @@ export const salvarConfigJitsi = mutation({
|
||||
useHttps: v.boolean(),
|
||||
acceptSelfSignedCert: v.boolean(),
|
||||
configuradoPorId: v.id("usuarios"),
|
||||
// Opcionais: configurações SSH/Docker
|
||||
sshHost: v.optional(v.string()),
|
||||
sshPort: v.optional(v.number()),
|
||||
sshUsername: v.optional(v.string()),
|
||||
sshPassword: v.optional(v.string()), // Senha nova (será criptografada)
|
||||
sshKeyPath: v.optional(v.string()),
|
||||
dockerComposePath: v.optional(v.string()),
|
||||
jitsiConfigPath: v.optional(v.string()),
|
||||
},
|
||||
returns: v.union(
|
||||
v.object({ sucesso: v.literal(true), configId: v.id("configuracaoJitsi") }),
|
||||
@@ -121,12 +74,6 @@ export const salvarConfigJitsi = mutation({
|
||||
};
|
||||
}
|
||||
|
||||
// Buscar config ativa anterior para manter senha SSH se não fornecida
|
||||
const configAtiva = await ctx.db
|
||||
.query("configuracaoJitsi")
|
||||
.withIndex("by_ativo", (q) => q.eq("ativo", true))
|
||||
.first();
|
||||
|
||||
// Desativar config anterior
|
||||
const configsAntigas = await ctx.db
|
||||
.query("configuracaoJitsi")
|
||||
@@ -137,16 +84,6 @@ export const salvarConfigJitsi = mutation({
|
||||
await ctx.db.patch(config._id, { ativo: false });
|
||||
}
|
||||
|
||||
// Determinar senha SSH: usar nova senha se fornecida, senão manter a atual
|
||||
let sshPasswordHash: string | undefined = undefined;
|
||||
if (args.sshPassword && args.sshPassword.trim().length > 0) {
|
||||
// Nova senha fornecida, criptografar
|
||||
sshPasswordHash = await encryptSMTPPassword(args.sshPassword);
|
||||
} else if (configAtiva && configAtiva.sshPasswordHash) {
|
||||
// Senha não fornecida, manter a atual (já criptografada)
|
||||
sshPasswordHash = configAtiva.sshPasswordHash;
|
||||
}
|
||||
|
||||
// Criar nova config
|
||||
const configId = await ctx.db.insert("configuracaoJitsi", {
|
||||
domain: args.domain.trim(),
|
||||
@@ -157,14 +94,6 @@ export const salvarConfigJitsi = mutation({
|
||||
ativo: true,
|
||||
configuradoPor: args.configuradoPorId,
|
||||
atualizadoEm: Date.now(),
|
||||
// Configurações SSH/Docker
|
||||
sshHost: args.sshHost?.trim() || undefined,
|
||||
sshPort: args.sshPort || undefined,
|
||||
sshUsername: args.sshUsername?.trim() || undefined,
|
||||
sshPasswordHash: sshPasswordHash,
|
||||
sshKeyPath: args.sshKeyPath?.trim() || undefined,
|
||||
dockerComposePath: args.dockerComposePath?.trim() || undefined,
|
||||
jitsiConfigPath: args.jitsiConfigPath?.trim() || undefined,
|
||||
});
|
||||
|
||||
// Log de atividade
|
||||
|
||||
Reference in New Issue
Block a user