[Parecer Juridico]
This commit is contained in:
@@ -603,6 +603,82 @@ class ChatService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renomeia uma pasta existente
|
||||
*
|
||||
* @param folderId - ID da pasta a ser renomeada
|
||||
* @param newName - Novo nome da pasta
|
||||
* @param userEmail - Email do usuário (opcional)
|
||||
* @returns Promise com o resultado da operação
|
||||
*/
|
||||
async renameFolder(folderId: string, newName: string, userEmail?: string): Promise<{ success: boolean; folder?: FolderRecord }> {
|
||||
const email = userEmail || GlobalFunctions.getTransferProperty(TransferAreaProperties.UsuarioEmail);
|
||||
|
||||
if (!email) {
|
||||
throw {
|
||||
success: false,
|
||||
message: 'Email do usuário não fornecido',
|
||||
};
|
||||
}
|
||||
|
||||
if (!folderId || folderId.trim().length === 0) {
|
||||
throw {
|
||||
success: false,
|
||||
message: 'ID da pasta não pode estar vazio',
|
||||
};
|
||||
}
|
||||
|
||||
if (!newName || newName.trim().length === 0) {
|
||||
throw {
|
||||
success: false,
|
||||
message: 'Nome da pasta não pode estar vazio',
|
||||
};
|
||||
}
|
||||
|
||||
console.log('Renomeando pasta:', {
|
||||
folderId,
|
||||
newName,
|
||||
userEmail: email,
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await apiService.put<Array<{ success: boolean; user_email?: string; name?: string; id?: string }>>(
|
||||
this.POST_FOLDER_ENDPOINT,
|
||||
{
|
||||
id: folderId,
|
||||
user_email: email,
|
||||
name: newName.trim(),
|
||||
}
|
||||
);
|
||||
|
||||
console.log('Resposta completa do PUT (renomear pasta):', response);
|
||||
console.log('response.data:', response.data);
|
||||
|
||||
// A API retorna um array com um objeto: [{"success":true, "user_email": "...", "name": "...", "id": "..."}]
|
||||
let result: { success: boolean; user_email?: string; name?: string; id?: string };
|
||||
|
||||
if (Array.isArray(response.data)) {
|
||||
result = response.data[0];
|
||||
console.log('API retornou array, usando primeiro elemento:', result);
|
||||
} else {
|
||||
result = response.data as any;
|
||||
console.log('API retornou objeto direto:', result);
|
||||
}
|
||||
|
||||
return {
|
||||
success: result.success ?? true,
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error('Erro ao renomear pasta:', error);
|
||||
|
||||
throw {
|
||||
success: false,
|
||||
message: error.message || 'Erro ao renomear pasta',
|
||||
status: error.status,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca todos os chats e pastas do usuário
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user