Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(group): validate a picture's base64 even when url is set

Yudhi Armyndharisbb1d13a74275
diff --git a/src/modules/group/dto/group.dto.spec.ts b/src/modules/group/dto/group.dto.spec.ts
index 935e4fd53..f68790d92 100644
--- a/src/modules/group/dto/group.dto.spec.ts
+++ b/src/modules/group/dto/group.dto.spec.ts
@@ -39,6 +39,9 @@ describe('group DTO validation', () => {
// A base64 that is only a data-URI prefix strips to nothing, so the url is what would be sent.
const prefixOnly = { url: 'cdn/group.jpg', base64: 'data:image/jpeg;base64,', mimetype: 'image/jpeg' };
expect((await errorsFor(SetGroupPictureDto, prefixOnly)).length).toBeGreaterThan(0);
+ // base64 wins when both are set, so a url alongside it must not switch off its type check.
+ const arrayBase64 = { url: 'https://a.example/x.jpg', base64: ['QUJD'], mimetype: 'image/jpeg' };
+ expect((await errorsFor(SetGroupPictureDto, arrayBase64)).some(e => e.property === 'base64')).toBe(true);
});
it('accepts a valid participants body (regression for #190)', async () => {
diff --git a/src/modules/group/dto/group.dto.ts b/src/modules/group/dto/group.dto.ts
index 37a2b3de8..813fa3e08 100644
--- a/src/modules/group/dto/group.dto.ts
+++ b/src/modules/group/dto/group.dto.ts
@@ -129,7 +129,6 @@ export class SetGroupPictureDto {
@ApiPropertyOptional({ description: 'Base64 encoded image data' })
@IsOptional()
@IsString()
- @ValidateIf((o: SetGroupPictureDto) => !o.url)
base64?: string;
@ApiPropertyOptional({ description: 'Image MIME type (required when using base64)', example: 'image/jpeg' })