mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: image editing (#24155)
This commit is contained in:
@@ -81,6 +81,49 @@ export const ValidateUUID = (options?: UUIDOptions & ApiPropertyOptions) => {
|
||||
);
|
||||
};
|
||||
|
||||
export function IsAxisAlignedRotation() {
|
||||
return ValidateBy(
|
||||
{
|
||||
name: 'isAxisAlignedRotation',
|
||||
validator: {
|
||||
validate(value: any) {
|
||||
return [0, 90, 180, 270].includes(value);
|
||||
},
|
||||
defaultMessage: buildMessage(
|
||||
(eachPrefix) => eachPrefix + '$property must be one of the following values: 0, 90, 180, 270',
|
||||
{},
|
||||
),
|
||||
},
|
||||
},
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
@ValidatorConstraint({ name: 'uniqueEditActions' })
|
||||
class UniqueEditActionsValidator implements ValidatorConstraintInterface {
|
||||
validate(edits: { action: string; parameters?: unknown }[]): boolean {
|
||||
if (!Array.isArray(edits)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const actionSet = new Set<string>();
|
||||
for (const edit of edits) {
|
||||
const key = edit.action === 'mirror' ? `${edit.action}-${JSON.stringify(edit.parameters)}` : edit.action;
|
||||
if (actionSet.has(key)) {
|
||||
return false;
|
||||
}
|
||||
actionSet.add(key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
defaultMessage(): string {
|
||||
return 'Duplicate edit actions are not allowed';
|
||||
}
|
||||
}
|
||||
|
||||
export const IsUniqueEditActions = () => Validate(UniqueEditActionsValidator);
|
||||
|
||||
export class UUIDParamDto {
|
||||
@IsNotEmpty()
|
||||
@IsUUID('4')
|
||||
|
||||
Reference in New Issue
Block a user