Fix shared post schema startup crash
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled

هذا الالتزام موجود في:
boutmoun123
2026-07-05 14:57:22 +03:00
الأصل 7cd239f8e0
التزام 830b0fdf84

عرض الملف

@@ -1,15 +1,9 @@
import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose';
import { HydratedDocument, Types } from 'mongoose';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, SchemaTypes, Types } from 'mongoose';
import { PostShareTarget } from '../dto/share-post.dto';
export type PostShareDocument = HydratedDocument<PostShare>;
export const sharedFromSchema = raw({
type: { type: String, enum: ['user', 'profile', 'feed', 'unknown'], default: 'unknown' },
id: { type: String, default: '' },
name: { type: String, default: '' },
});
@Schema({ timestamps: true, versionKey: false, collection: 'postshares' })
export class PostShare {
@Prop({ type: Types.ObjectId, required: true, index: true })
@@ -21,8 +15,14 @@ export class PostShare {
@Prop({ type: Types.ObjectId, required: true, index: true })
originalAuthorId!: Types.ObjectId;
@Prop({ type: sharedFromSchema, default: null })
sharedFrom?: { type: 'user' | 'profile' | 'feed' | 'unknown'; id?: string; name?: string } | null;
@Prop({ type: SchemaTypes.Mixed, default: undefined })
sharedFrom?: {
type: 'user' | 'profile' | 'feed' | 'unknown';
id?: string;
name?: string;
username?: string;
avatar?: string;
};
@Prop({ type: String, enum: Object.values(PostShareTarget), default: PostShareTarget.PROFILE, index: true })
target!: PostShareTarget;