Add Instagram-style social features and Postman collections

هذا الالتزام موجود في:
boutmoun123
2026-05-24 15:21:03 +03:00
الأصل fdc40192f7
التزام 367fce6557
56 ملفات معدلة مع 20266 إضافات و5965 حذوفات

عرض الملف

@@ -20,6 +20,13 @@ export type PostMediaVariantSet = {
highUrl: string;
};
export type PostImageItem = {
url: string;
caption: string;
altText: string;
order: number;
};
const mediaVariantSetSchema = raw({
originalUrl: { type: String, default: '' },
lowUrl: { type: String, default: '' },
@@ -27,11 +34,24 @@ const mediaVariantSetSchema = raw({
highUrl: { type: String, default: '' },
});
const imageItemSchema = raw({
url: { type: String, default: '' },
caption: { type: String, default: '' },
altText: { type: String, default: '' },
order: { type: Number, default: 0 },
});
@Schema({ timestamps: true, versionKey: false })
export class Post {
@Prop({ type: Types.ObjectId, ref: User.name, required: true, index: true })
authorId!: Types.ObjectId;
@Prop({ type: Types.ObjectId, ref: 'Post', default: null, index: true })
repostOfPostId?: Types.ObjectId | null;
@Prop({ type: Types.ObjectId, ref: 'Post', default: null, index: true })
quoteOfPostId?: Types.ObjectId | null;
@Prop({ default: '', trim: true, maxlength: 2200, required: true })
content!: string;
@@ -68,6 +88,9 @@ export class Post {
@Prop({ type: [String], default: [] })
imageUrls!: string[];
@Prop({ type: [imageItemSchema], default: [] })
imageItems!: PostImageItem[];
@Prop({ type: [mediaVariantSetSchema], default: [] })
imageVariants!: PostMediaVariantSet[];
@@ -77,6 +100,9 @@ export class Post {
@Prop({ type: [String], default: [] })
mentionUsernames!: string[];
@Prop({ type: [Types.ObjectId], ref: User.name, default: [], index: true })
collaboratorIds!: Types.ObjectId[];
@Prop({ default: '' })
location!: string;
@@ -110,6 +136,21 @@ export class Post {
@Prop({ default: 0, min: 0 })
playCount!: number;
@Prop({ default: false, index: true })
commentsDisabled!: boolean;
@Prop({ default: false })
commentsFollowersOnly!: boolean;
@Prop({ type: [String], default: [] })
commentFilterKeywords!: string[];
@Prop({ default: false, index: true })
pinnedToProfile!: boolean;
@Prop({ default: false, index: true })
isArchived!: boolean;
@Prop({ type: [String], default: [], index: true })
hashtags!: string[];
@@ -137,10 +178,15 @@ export class Post {
export const PostSchema = SchemaFactory.createForClass(Post);
PostSchema.index({ authorId: 1, createdAt: -1 });
PostSchema.index({ repostOfPostId: 1, createdAt: -1 });
PostSchema.index({ quoteOfPostId: 1, createdAt: -1 });
PostSchema.index({ visibility: 1, createdAt: -1 });
PostSchema.index({ postType: 1, createdAt: -1 });
PostSchema.index({ hashtags: 1, createdAt: -1 });
PostSchema.index({ taggedUserIds: 1, createdAt: -1 });
PostSchema.index({ collaboratorIds: 1, createdAt: -1 });
PostSchema.index({ authorId: 1, pinnedToProfile: -1, createdAt: -1 });
PostSchema.index({ authorId: 1, isArchived: 1, createdAt: -1 });
PostSchema.index({ moderationStatus: 1, createdAt: -1 });
PostSchema.index({ authorId: 1, isDeleted: 1, createdAt: -1 });
PostSchema.index({ visibility: 1, isDeleted: 1, createdAt: -1 });
@@ -158,6 +204,12 @@ PostSchema.index({
const transformManagedPostFiles = (_doc: unknown, ret: any) => {
ret.imageUrls = resolveManagedFileUrls(ret.imageUrls);
ret.imageItems = Array.isArray(ret.imageItems)
? ret.imageItems.map((item: PostImageItem) => ({
...item,
url: resolveManagedFileUrl(item.url),
}))
: [];
ret.imageVariants = resolveManagedFileUrlRecords(ret.imageVariants);
ret.videoUrl = resolveManagedFileUrl(ret.videoUrl);
ret.hlsUrl = resolveManagedFileUrl(ret.hlsUrl);