public async Task AddUsersToBlacklist() { var user = fillTestDbHelper.Users.LastOrDefault(opt => !opt.Deleted && opt.Confirmed.GetValueOrDefault()); var expectedUsersIds = fillTestDbHelper.Users.Select(opt => opt.Id).Take(2).ToList(); var usersIds = await updateUsersService.AddUsersToBlackListAsync(expectedUsersIds, user.Id); var actual = await loadUsersService.GetUserInformationAsync(user.Id); Assert.True(actual.BlackList.Intersect(usersIds).OrderBy(id => id).SequenceEqual(usersIds.OrderBy(id => id))); }
public async Task HandleAsync() { await updateUsersService.AddUsersToBlackListAsync(notice.BlacklistedUsersIds, notice.UserId).ConfigureAwait(false); var segment = await BlockSegmentsService.Instance.CreateUsersAddedToUserBlacklistSegmentAsync( 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); }
public async Task <Response> CreateResponseAsync() { try { var blockedUsersId = await updateUsersService.AddUsersToBlackListAsync(request.UsersId, clientConnection.UserId.GetValueOrDefault()).ConfigureAwait(false); if (blockedUsersId.Any()) { nodeNoticeService.SendUsersAddedToUserBlacklistNodeNoticeAsync( blockedUsersId.ToList(), clientConnection.UserId.GetValueOrDefault()); BlockSegmentVm segment = await BlockSegmentsService.Instance.CreateUsersAddedToUserBlacklistSegmentAsync( blockedUsersId, clientConnection.UserId.GetValueOrDefault(), NodeSettings.Configs.Node.Id, NodeData.Instance.NodeKeys.SignPrivateKey, NodeData.Instance.NodeKeys.SymmetricKey, NodeData.Instance.NodeKeys.Password, NodeData.Instance.NodeKeys.KeyId).ConfigureAwait(false); BlockGenerationHelper.Instance.AddSegment(segment); nodeNoticeService.SendBlockSegmentsNodeNoticeAsync(new List <BlockSegmentVm> { segment }); UsersConversationsCacheService.Instance.UpdateUsersDialogsAsync( blockedUsersId.Append(clientConnection.UserId.GetValueOrDefault())); } return(new ResultResponse(request.RequestId)); } catch (ObjectDoesNotExistsException ex) { Logger.WriteLog(ex); return(new ResultResponse(request.RequestId, "Users not found.", ErrorCode.ObjectDoesNotExists)); } }