Add adaptive media variants for weak networks
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
هذا الالتزام موجود في:
@@ -1,16 +1,32 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose';
|
||||
import { HydratedDocument, Types } from 'mongoose';
|
||||
import { ModerationStatus } from '../../../common/enums/moderation-status.enum';
|
||||
import { PostType } from '../../../common/enums/post-type.enum';
|
||||
import { PostVisibility } from '../../../common/enums/post-visibility.enum';
|
||||
import {
|
||||
resolveManagedFileUrl,
|
||||
resolveManagedFileUrlRecord,
|
||||
resolveManagedFileUrlRecords,
|
||||
resolveManagedFileUrls,
|
||||
} from '../../../common/utils/public-url.util';
|
||||
import { User } from '../../users/schemas/user.schema';
|
||||
|
||||
export type PostDocument = HydratedDocument<Post>;
|
||||
|
||||
export type PostMediaVariantSet = {
|
||||
originalUrl: string;
|
||||
lowUrl: string;
|
||||
mediumUrl: string;
|
||||
highUrl: string;
|
||||
};
|
||||
|
||||
const mediaVariantSetSchema = raw({
|
||||
originalUrl: { type: String, default: '' },
|
||||
lowUrl: { type: String, default: '' },
|
||||
mediumUrl: { type: String, default: '' },
|
||||
highUrl: { type: String, default: '' },
|
||||
});
|
||||
|
||||
@Schema({ timestamps: true, versionKey: false })
|
||||
export class Post {
|
||||
@Prop({ type: Types.ObjectId, ref: User.name, required: true, index: true })
|
||||
@@ -34,6 +50,9 @@ export class Post {
|
||||
@Prop({ default: '' })
|
||||
thumbnailUrl!: string;
|
||||
|
||||
@Prop({ type: mediaVariantSetSchema, default: null })
|
||||
thumbnailVariants!: PostMediaVariantSet | null;
|
||||
|
||||
@Prop({ default: '', trim: true, maxlength: 80 })
|
||||
style!: string;
|
||||
|
||||
@@ -49,6 +68,9 @@ export class Post {
|
||||
@Prop({ type: [String], default: [] })
|
||||
imageUrls!: string[];
|
||||
|
||||
@Prop({ type: [mediaVariantSetSchema], default: [] })
|
||||
imageVariants!: PostMediaVariantSet[];
|
||||
|
||||
@Prop({ type: [Types.ObjectId], ref: User.name, default: [], index: true })
|
||||
taggedUserIds!: Types.ObjectId[];
|
||||
|
||||
@@ -136,10 +158,12 @@ PostSchema.index({
|
||||
|
||||
const transformManagedPostFiles = (_doc: unknown, ret: any) => {
|
||||
ret.imageUrls = resolveManagedFileUrls(ret.imageUrls);
|
||||
ret.imageVariants = resolveManagedFileUrlRecords(ret.imageVariants);
|
||||
ret.videoUrl = resolveManagedFileUrl(ret.videoUrl);
|
||||
ret.hlsUrl = resolveManagedFileUrl(ret.hlsUrl);
|
||||
ret.audioUrl = resolveManagedFileUrl(ret.audioUrl);
|
||||
ret.thumbnailUrl = resolveManagedFileUrl(ret.thumbnailUrl);
|
||||
ret.thumbnailVariants = resolveManagedFileUrlRecord(ret.thumbnailVariants);
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم