Ejemplo n.º 1
0
        public async Task DeleteDialog()
        {
            var dialog = fillTestDbHelper.Dialogs.FirstOrDefault();
            await deleteDialogsService.DeleteDialogAsync(dialog.Id, dialog.FirstUID);

            Assert.Null(fillTestDbHelper.Dialogs.FirstOrDefault(opt => opt.Id == dialog.Id));
        }
Ejemplo n.º 2
0
        public async Task <Response> CreateResponseAsync()
        {
            try
            {
                switch (request.ConversationType)
                {
                case ConversationType.Dialog:
                {
                    var users = await loadDialogsService.GetDialogUsersAsync(request.ConversationId).ConfigureAwait(false);

                    await deleteDialogsService.DeleteDialogAsync(request.ConversationId, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false);

                    UsersConversationsCacheService.Instance.UpdateUsersDialogsAsync(users.Select(opt => opt.Id.Value));
                }
                break;

                case ConversationType.Chat:
                {
                    List <long> usersId = await loadChatsService.GetChatUsersIdAsync(request.ConversationId).ConfigureAwait(false);

                    await deleteChatsService.DeleteChatAsync(request.ConversationId, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false);

                    UsersConversationsCacheService.Instance.UpdateUsersChatsAsync(usersId);
                    BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateDeleteChatSegmentAsync(
                        request.ConversationId, NodeSettings.Configs.Node.Id).ConfigureAwait(false);

                    BlockGenerationHelper.Instance.AddSegment(segment);
                }
                break;

                case ConversationType.Channel:
                {
                    List <long> usersId = await loadChannelsService.GetChannelUsersIdAsync(request.ConversationId).ConfigureAwait(false);

                    await deleteChannelsService.DeleteChannelAsync(request.ConversationId, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false);

                    UsersConversationsCacheService.Instance.UpdateUsersChannelsAsync(usersId);
                    BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateDeleteChannelSegmentAsync(
                        request.ConversationId, NodeSettings.Configs.Node.Id).ConfigureAwait(false);

                    BlockGenerationHelper.Instance.AddSegment(segment);
                }
                break;
                }
                nodeNoticeService.SendDeleteConversationsNodeNoticeAsync(request.ConversationId, request.ConversationType, clientConnection.UserId.GetValueOrDefault());
                return(new ResultResponse(request.RequestId));
            }
            catch (PermissionDeniedException ex)
            {
                Logger.WriteLog(ex, request);
                return(new ResultResponse(request.RequestId, "Conversation not found or user does not have access to conversation.", ErrorCode.DeleteConversationProblem));
            }
        }
Ejemplo n.º 3
0
        public async Task HandleAsync()
        {
            switch (notice.ConversationType)
            {
            case ConversationType.Dialog:
            {
                List <long> dialogsId = await loadDialogsService.GetDialogsIdByUsersIdPairAsync(notice.RequestingUserId, notice.ConversationId).ConfigureAwait(false);

                await deleteDialogsService.DeleteDialogAsync(dialogsId.FirstOrDefault(), notice.RequestingUserId).ConfigureAwait(false);

                UsersConversationsCacheService.Instance.UpdateUsersDialogsAsync(notice.RequestingUserId, notice.ConversationId);
            }
            break;

            case ConversationType.Chat:
            {
                var usersId = await loadChatsService.GetChatUsersIdAsync(notice.ConversationId).ConfigureAwait(false);

                await deleteChatsService.DeleteChatAsync(notice.ConversationId, notice.RequestingUserId).ConfigureAwait(false);

                UsersConversationsCacheService.Instance.UpdateUsersChatsAsync(usersId);
                BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateDeleteChatSegmentAsync(notice.ConversationId, notice.NodeId).ConfigureAwait(false);

                BlockGenerationHelper.Instance.AddSegment(segment);
            }
            break;

            case ConversationType.Channel:
            {
                var usersId = await loadChannelsService.GetChannelUsersIdAsync(notice.ConversationId).ConfigureAwait(false);

                await deleteChannelsService.DeleteChannelAsync(notice.ConversationId, notice.RequestingUserId).ConfigureAwait(false);

                UsersConversationsCacheService.Instance.UpdateUsersChannelsAsync(usersId);
                BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateDeleteChannelSegmentAsync(notice.ConversationId, notice.NodeId).ConfigureAwait(false);

                BlockGenerationHelper.Instance.AddSegment(segment);
            }
            break;
            }
        }