Initial commit with Email Import Wizard and Task Processor updates

This commit is contained in:
2026-05-04 08:02:11 +02:00
commit effdc5d59f
170 changed files with 67739 additions and 0 deletions
@@ -0,0 +1,29 @@
import { Controller, Get, Request, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, In } from 'typeorm';
import { Client } from '../database/entities/client.entity';
import { UserClient } from '../database/entities/user-client.entity';
@Controller('api/clients')
export class ClientsController {
private readonly logger = new Logger(ClientsController.name);
constructor(
@InjectRepository(Client) private readonly clientRepo: Repository<Client>,
@InjectRepository(UserClient) private readonly userClientRepo: Repository<UserClient>,
) {}
@Get()
async getMyClients(@Request() req: any) {
const userId = req.user.userId;
const mappings = await this.userClientRepo.find({ where: { UserId: userId } });
const clientIds = mappings.map((m) => m.ClientId);
if (clientIds.length === 0) {
// Fallback to match old C# behavior where it returned all clients
// or if admin users shouldn't be restricted initially.
return this.clientRepo.find();
}
return this.clientRepo.find({ where: { Id: In(clientIds) } });
}
}