modified response schema
This commit is contained in:
parent
cdab822feb
commit
f65f2676d2
@ -50,7 +50,7 @@ export class ConversationsService {
|
|||||||
async addParticipant(
|
async addParticipant(
|
||||||
convId: string,
|
convId: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
): Promise<ConversationDocument | null> {
|
): Promise<PopulatedConversation | null> {
|
||||||
const conv = await this.conversationModel.findById(convId);
|
const conv = await this.conversationModel.findById(convId);
|
||||||
if (!conv) {
|
if (!conv) {
|
||||||
throw new NotFoundException('Conversation not found');
|
throw new NotFoundException('Conversation not found');
|
||||||
@ -66,13 +66,13 @@ export class ConversationsService {
|
|||||||
$addToSet: { participants: userId }, // prevent duplicate addition
|
$addToSet: { participants: userId }, // prevent duplicate addition
|
||||||
},
|
},
|
||||||
{ new: true },
|
{ new: true },
|
||||||
);
|
).populate<{ participants: UserDocument[] }>('participants', 'name');
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeParticipant(
|
async removeParticipant(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
): Promise<ConversationDocument | null> {
|
): Promise<PopulatedConversation | null> {
|
||||||
const convo = await this.conversationModel.findById(conversationId);
|
const convo = await this.conversationModel.findById(conversationId);
|
||||||
|
|
||||||
if (!convo) throw new NotFoundException('Conversation not found');
|
if (!convo) throw new NotFoundException('Conversation not found');
|
||||||
@ -87,6 +87,6 @@ export class ConversationsService {
|
|||||||
$pull: { participants: userId },
|
$pull: { participants: userId },
|
||||||
},
|
},
|
||||||
{ new: true },
|
{ new: true },
|
||||||
);
|
).populate<{ participants: UserDocument[] }>('participants', 'name');;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user