Add chat hiding mentions follow counts waveform and post fixes
This commit is contained in:
@@ -62,7 +62,10 @@ export class CollaborationRequestsService {
|
||||
throw new NotFoundException('Post not found');
|
||||
}
|
||||
|
||||
const targetUserId = post.authorId.toString();
|
||||
const targetUserId = this.extractEntityId(post.authorId);
|
||||
if (!Types.ObjectId.isValid(targetUserId)) {
|
||||
throw new BadRequestException('Post owner is invalid');
|
||||
}
|
||||
|
||||
if (requesterId === targetUserId) {
|
||||
throw new BadRequestException('You cannot request collaboration on your own post');
|
||||
@@ -345,10 +348,11 @@ export class CollaborationRequestsService {
|
||||
private buildCollaborationDetails(
|
||||
dto: CreateCollaborationRequestDto | CreateGeneralCollaborationRequestDto,
|
||||
) {
|
||||
const attachmentUrl = typeof dto.attachmentUrl === 'string' ? dto.attachmentUrl.trim() : '';
|
||||
return {
|
||||
...(dto.collaborationType ? { collaborationType: dto.collaborationType } : {}),
|
||||
...(typeof dto.message === 'string' ? { message: dto.message.trim() } : {}),
|
||||
...(typeof dto.attachmentUrl === 'string' ? { attachmentUrl: dto.attachmentUrl.trim() } : {}),
|
||||
...(attachmentUrl ? { attachmentUrl } : {}),
|
||||
...(dto.attachmentType ? { attachmentType: dto.attachmentType } : {}),
|
||||
};
|
||||
}
|
||||
@@ -565,4 +569,29 @@ export class CollaborationRequestsService {
|
||||
deepLink: `/users/${actorId}`,
|
||||
};
|
||||
}
|
||||
|
||||
private extractEntityId(value: unknown): string {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
if (value instanceof Types.ObjectId) {
|
||||
return value.toString();
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
const candidate = value as { _id?: unknown; id?: unknown };
|
||||
if (candidate._id instanceof Types.ObjectId) {
|
||||
return candidate._id.toString();
|
||||
}
|
||||
if (typeof candidate._id === 'string') {
|
||||
return candidate._id;
|
||||
}
|
||||
if (typeof candidate.id === 'string') {
|
||||
return candidate.id;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user