Chat settings in Super Admin and changing the chat title and position.

This commit is contained in:
2026-09-29 14:45:19 +03:30
parent 125976f3eb
commit 66af7e577c
14 changed files with 332 additions and 269 deletions
+27 -21
View File
@@ -25,7 +25,6 @@ import { CurrentUser } from '../auth/current-user.decorator';
import type { Actor } from '../common/record-scope';
import { OrgModuleGuard } from '../billing/org-module.guard';
import { RequireOrgModule } from '../billing/org-module.decorator';
import { cellStr } from '../common/excel';
import { brand } from '@mento/shared';
import {
AssignLeadsDto,
@@ -139,36 +138,43 @@ export class LeadsController {
);
}
@Post('import/preview')
@UseGuards(RolesGuard)
@Roles('owner', 'admin')
@UseInterceptors(
FileInterceptor('file', {
storage: memoryStorage(),
limits: { fileSize: 15_000_000 },
}),
)
importPreview(@UploadedFile() file?: Express.Multer.File) {
if (!file?.buffer?.length) {
throw new BadRequestException('فایل ارسال نشده');
}
return this.imports.preview(file);
}
@Post('import/file')
@UseGuards(RolesGuard)
@Roles('owner', 'admin')
@UseInterceptors(FileInterceptor('file'))
@UseInterceptors(
FileInterceptor('file', {
storage: memoryStorage(),
limits: { fileSize: 15_000_000 },
}),
)
async importFile(
@CurrentUser() user: Actor,
@UploadedFile() file?: Express.Multer.File,
@Body('mapping') mapping?: string,
) {
if (!file?.buffer?.length) {
throw new BadRequestException('فایل ارسال نشده');
}
const wb = new ExcelJS.Workbook();
await wb.xlsx.load(Uint8Array.from(file.buffer) as unknown as ExcelJS.Buffer);
const sheet = wb.worksheets[0];
if (!sheet) throw new BadRequestException('برگه اکسل خالی است');
const headerRow = sheet.getRow(1);
const headers: string[] = [];
headerRow.eachCell({ includeEmpty: true }, (cell, col) => {
headers[col - 1] = cellStr(cell.value);
});
const rows: Array<Record<string, string>> = [];
sheet.eachRow({ includeEmpty: false }, (row, rowNumber) => {
if (rowNumber === 1) return;
const obj: Record<string, string> = {};
headers.forEach((h, i) => {
if (!h) return;
obj[h] = cellStr(row.getCell(i + 1).value);
});
if (Object.values(obj).some((v) => v.trim())) rows.push(obj);
});
const rows = await this.imports.rowsFromFile(file, mapping);
if (!rows.length) {
throw new BadRequestException('ردیفی برای ایمپورت نیست');
}
return this.imports.enqueue(
user.organizationId,
user.userId,