feat: implement conversation mute and favorite functionality with corresponding notification suppression.

This commit is contained in:
pradeepkumar
2026-03-19 17:04:02 +05:30
parent 870eb0c067
commit fcf90e8638
4 changed files with 108 additions and 0 deletions

View File

@@ -218,6 +218,36 @@ export class MessagesController {
return this.messagesService.markMessagesAsRead(conversationId, userId);
}
// ==========================================
// TOGGLE MUTE
// ==========================================
@Patch('conversations/:id/mute')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Mute or unmute conversation notifications' })
@ApiParam({ name: 'id', description: 'Conversation ID' })
async toggleMute(
@Param('id') conversationId: string,
@CurrentUser('id') userId: string,
@Body() dto: { muted: boolean },
) {
return this.messagesService.toggleMute(conversationId, userId, dto.muted);
}
// ==========================================
// TOGGLE FAVORITE
// ==========================================
@Patch('conversations/:id/favorite')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Star or unstar a conversation' })
@ApiParam({ name: 'id', description: 'Conversation ID' })
async toggleFavorite(
@Param('id') conversationId: string,
@CurrentUser('id') userId: string,
@Body() dto: { favorited: boolean },
) {
return this.messagesService.toggleFavorite(conversationId, userId, dto.favorited);
}
// ==========================================
// CLEAR CHAT (delete messages, keep conversation)
// ==========================================