forked from Yara724/api
Merge pull request 'reduced minimum bytes of medias' (#91) from s.yahyaee/yara724-api:main into main
Reviewed-on: Yara724/api#91
This commit is contained in:
@@ -47,7 +47,7 @@ export interface MediaLimits {
|
|||||||
* receive. Per-client `maxBytes` cannot legitimately go above its route's
|
* receive. Per-client `maxBytes` cannot legitimately go above its route's
|
||||||
* multer ceiling, so the defaults below are kept at-or-below those.
|
* multer ceiling, so the defaults below are kept at-or-below those.
|
||||||
*/
|
*/
|
||||||
export const DEFAULT_MEDIA_MIN_BYTES = 20 * 1024; // 100KB
|
export const DEFAULT_MEDIA_MIN_BYTES = 10; // 10 Byte
|
||||||
export const DEFAULT_MEDIA_MAX_BYTES = 100 * 1024 * 1024; // 100MB
|
export const DEFAULT_MEDIA_MAX_BYTES = 100 * 1024 * 1024; // 100MB
|
||||||
|
|
||||||
export const DEFAULT_MEDIA_LIMITS: Record<MediaKind, MediaLimits> = {
|
export const DEFAULT_MEDIA_LIMITS: Record<MediaKind, MediaLimits> = {
|
||||||
@@ -185,13 +185,19 @@ export class ClientService {
|
|||||||
_id: new Types.ObjectId(idString),
|
_id: new Types.ObjectId(idString),
|
||||||
});
|
});
|
||||||
const configured = client?.settings?.carBodyAccidentMaxAgeDays;
|
const configured = client?.settings?.carBodyAccidentMaxAgeDays;
|
||||||
if (typeof configured === "number" && Number.isFinite(configured) && configured > 0) {
|
if (
|
||||||
|
typeof configured === "number" &&
|
||||||
|
Number.isFinite(configured) &&
|
||||||
|
configured > 0
|
||||||
|
) {
|
||||||
return configured;
|
return configured;
|
||||||
}
|
}
|
||||||
return DEFAULT_CAR_BODY_ACCIDENT_MAX_AGE_DAYS;
|
return DEFAULT_CAR_BODY_ACCIDENT_MAX_AGE_DAYS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private resolveClientObjectId(clientKey: string | Types.ObjectId): Types.ObjectId {
|
private resolveClientObjectId(
|
||||||
|
clientKey: string | Types.ObjectId,
|
||||||
|
): Types.ObjectId {
|
||||||
const raw = String(clientKey ?? "").trim();
|
const raw = String(clientKey ?? "").trim();
|
||||||
if (!Types.ObjectId.isValid(raw)) {
|
if (!Types.ObjectId.isValid(raw)) {
|
||||||
throw new BadRequestException("Invalid client key");
|
throw new BadRequestException("Invalid client key");
|
||||||
@@ -293,7 +299,8 @@ export class ClientService {
|
|||||||
const $set: Record<string, unknown> = {};
|
const $set: Record<string, unknown> = {};
|
||||||
|
|
||||||
if (body.carBodyAccidentMaxAgeDays !== undefined) {
|
if (body.carBodyAccidentMaxAgeDays !== undefined) {
|
||||||
$set["settings.carBodyAccidentMaxAgeDays"] = body.carBodyAccidentMaxAgeDays;
|
$set["settings.carBodyAccidentMaxAgeDays"] =
|
||||||
|
body.carBodyAccidentMaxAgeDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.media) {
|
if (body.media) {
|
||||||
|
|||||||
Reference in New Issue
Block a user