Fix admin settings save 400 and remove JSON socials editor.

Send only whitelisted fields and let operators edit social links as simple label/url rows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-30 21:06:33 +03:30
co-authored by Cursor
parent 002deb5e13
commit bf75e52ad3
3 changed files with 103 additions and 24 deletions
+16 -3
View File
@@ -1,7 +1,16 @@
import { Body, Controller, Get, Param, Put, UseGuards } from "@nestjs/common";
import { ContentService } from "./content.service";
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
import { IsObject, IsOptional, IsString } from "class-validator";
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
class SocialDto {
@IsString()
label!: string;
@IsString()
url!: string;
}
class UpdateSettingsDto {
@IsOptional() @IsString() brandName?: string;
@@ -10,8 +19,12 @@ class UpdateSettingsDto {
@IsOptional() @IsString() phone?: string;
@IsOptional() @IsString() address?: string;
@IsOptional() @IsString() timezone?: string;
@IsOptional() socials?: object;
@IsOptional() @IsString() logoUrl?: string;
@IsOptional() @IsString() logoUrl?: string | null;
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => SocialDto)
socials?: SocialDto[];
}
class UpsertSectionDto {
+8 -1
View File
@@ -19,7 +19,14 @@ export class ContentService {
socials?: object;
logoUrl?: string | null;
}) {
return this.prisma.siteSettings.update({ where: { id: "default" }, data });
const { logoUrl, ...rest } = data;
return this.prisma.siteSettings.update({
where: { id: "default" },
data: {
...rest,
...(logoUrl !== undefined ? { logoUrl: logoUrl || null } : {}),
},
});
}
async listSections() {