Fix shared post schema startup crash
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
هذا الالتزام موجود في:
@@ -1,15 +1,9 @@
|
|||||||
import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose';
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||||
import { HydratedDocument, Types } from 'mongoose';
|
import { HydratedDocument, SchemaTypes, Types } from 'mongoose';
|
||||||
import { PostShareTarget } from '../dto/share-post.dto';
|
import { PostShareTarget } from '../dto/share-post.dto';
|
||||||
|
|
||||||
export type PostShareDocument = HydratedDocument<PostShare>;
|
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' })
|
@Schema({ timestamps: true, versionKey: false, collection: 'postshares' })
|
||||||
export class PostShare {
|
export class PostShare {
|
||||||
@Prop({ type: Types.ObjectId, required: true, index: true })
|
@Prop({ type: Types.ObjectId, required: true, index: true })
|
||||||
@@ -21,8 +15,14 @@ export class PostShare {
|
|||||||
@Prop({ type: Types.ObjectId, required: true, index: true })
|
@Prop({ type: Types.ObjectId, required: true, index: true })
|
||||||
originalAuthorId!: Types.ObjectId;
|
originalAuthorId!: Types.ObjectId;
|
||||||
|
|
||||||
@Prop({ type: sharedFromSchema, default: null })
|
@Prop({ type: SchemaTypes.Mixed, default: undefined })
|
||||||
sharedFrom?: { type: 'user' | 'profile' | 'feed' | 'unknown'; id?: string; name?: string } | null;
|
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 })
|
@Prop({ type: String, enum: Object.values(PostShareTarget), default: PostShareTarget.PROFILE, index: true })
|
||||||
target!: PostShareTarget;
|
target!: PostShareTarget;
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم