public async Task MuteConversation() { var expectedChat = fillTestDbHelper.Chats.FirstOrDefault(); await conversationsService.MuteConversationAsync(ConversationType.Chat, expectedChat.Id, expectedChat.ChatUsers.FirstOrDefault().UserId); var actualChat = fillTestDbHelper.Chats.FirstOrDefault(opt => opt.Id == expectedChat.Id); Assert.True(actualChat.ChatUsers.FirstOrDefault().IsMuted); var expectedChannel = fillTestDbHelper.Channels.FirstOrDefault(); await conversationsService.MuteConversationAsync(ConversationType.Channel, expectedChannel.ChannelId, expectedChannel.ChannelUsers.FirstOrDefault().UserId); var actualChannel = fillTestDbHelper.Channels.FirstOrDefault(opt => opt.ChannelId == expectedChannel.ChannelId); Assert.True(actualChannel.ChannelUsers.FirstOrDefault().IsMuted); var expectedDialog = fillTestDbHelper.Dialogs.FirstOrDefault(); await conversationsService.MuteConversationAsync(ConversationType.Dialog, expectedDialog.Id, expectedDialog.FirstUID); var actualDialog = fillTestDbHelper.Dialogs.FirstOrDefault(opt => opt.Id == expectedDialog.Id); Assert.True(actualDialog.IsMuted); }
public async Task <Response> CreateResponseAsync() { try { await conversationsService.MuteConversationAsync( request.ConversationType, request.ConversationId, clientConnection.UserId).ConfigureAwait(false); UsersConversationsCacheService.Instance.ConversationMutedUpdateConversations( request.ConversationId, request.ConversationType, clientConnection.UserId.Value); return(new ResultResponse(request.RequestId)); } catch (PermissionDeniedException) { return(new ResultResponse(request.RequestId, "The user does not have access to the conversation.", ObjectsLibrary.Enums.ErrorCode.PermissionDenied)); } }