modified response schema

This commit is contained in:
Suman991 2026-04-17 14:21:45 +05:30
parent cdab822feb
commit f65f2676d2

View File

@ -50,7 +50,7 @@ export class ConversationsService {
async addParticipant(
convId: string,
userId: string,
): Promise<ConversationDocument | null> {
): Promise<PopulatedConversation | null> {
const conv = await this.conversationModel.findById(convId);
if (!conv) {
throw new NotFoundException('Conversation not found');
@ -66,13 +66,13 @@ export class ConversationsService {
$addToSet: { participants: userId }, // prevent duplicate addition
},
{ new: true },
);
).populate<{ participants: UserDocument[] }>('participants', 'name');
}
async removeParticipant(
conversationId: string,
userId: string,
): Promise<ConversationDocument | null> {
): Promise<PopulatedConversation | null> {
const convo = await this.conversationModel.findById(conversationId);
if (!convo) throw new NotFoundException('Conversation not found');
@ -87,6 +87,6 @@ export class ConversationsService {
$pull: { participants: userId },
},
{ new: true },
);
).populate<{ participants: UserDocument[] }>('participants', 'name');;
}
}