Beispiel #1
0
        public async Task <Response> CreateResponseAsync()
        {
            try
            {
                List <long> usersId = await updateUsersService.DeleteUsersFromBlackListAsync(request.UsersId, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false);

                if (usersId.Any())
                {
                    nodeNoticeService.SendUsersRemovedFromBlacklistNodeNoticeAsync(usersId.ToList(), clientConnection.UserId.GetValueOrDefault());
                    BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateUsersRemovedFromUserBlacklistSegmentAsync(
                        usersId,
                        clientConnection.UserId.GetValueOrDefault(),
                        NodeSettings.Configs.Node.Id,
                        NodeData.Instance.NodeKeys.PrivateKey,
                        NodeData.Instance.NodeKeys.SymmetricKey,
                        NodeData.Instance.NodeKeys.Password,
                        NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false);

                    BlockGenerationHelper.Instance.AddSegment(segment);
                    UsersConversationsCacheService.Instance.UpdateUsersDialogsAsync(usersId.Append(clientConnection.UserId.GetValueOrDefault()));
                    nodeNoticeService.SendBlockSegmentsNodeNoticeAsync(new List <BlockSegmentVm> {
                        segment
                    });
                }
                return(new ResultResponse(request.RequestId));
            }
            catch (ObjectDoesNotExistsException ex)
            {
                Logger.WriteLog(ex, request);
                return(new ResultResponse(request.RequestId, "Users not found.", ErrorCode.ObjectDoesNotExists));
            }
        }
Beispiel #2
0
        public async Task RemoveUsersFromBlacklist()
        {
            var user             = fillTestDbHelper.Users.FirstOrDefault();
            var expectedUsersIds = fillTestDbHelper.Users.Select(opt => opt.Id).Take(2).ToList();
            var addedUsersIds    = await updateUsersService.AddUsersToBlackListAsync(expectedUsersIds, user.Id);

            var removedUsersIds = await updateUsersService.DeleteUsersFromBlackListAsync(addedUsersIds, user.Id);

            var actual = await loadUsersService.GetUserInformationAsync(user.Id);

            Assert.Empty(actual.BlackList);
        }
        public async Task HandleAsync()
        {
            await updateUsersService.DeleteUsersFromBlackListAsync(notice.BlacklistedUsersIds, notice.UserId).ConfigureAwait(false);

            var segment = await BlockSegmentsService.Instance.CreateUsersRemovedFromUserBlacklistSegmentAsync(
                notice.BlacklistedUsersIds,
                notice.UserId,
                current.Node.Id,
                NodeData.Instance.NodeKeys.SignPrivateKey,
                NodeData.Instance.NodeKeys.SymmetricKey,
                NodeData.Instance.NodeKeys.Password,
                NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false);

            BlockGenerationHelper.Instance.AddSegment(segment);
        }