async Task ValidateAllProfiles(bool informUsers = false) { if (informUsers) { await slackIntegration.SendDirectMessage(adminUser, "Notifying all users"); } else { await slackIntegration.SendDirectMessage(adminUser, "Validating all users"); } async Task <string> ValidateAllProfiles() { var usersWithIncompleteProfiles = new List <ProfileValidationResult>(); foreach (var user in await slackIntegration.GetAllUsers()) { await slackIntegration.IndicateTyping(adminUser); var verificationResult = await slackProfileValidator.ValidateProfile(user); if (verificationResult.IsValid) { continue; } usersWithIncompleteProfiles.Add(verificationResult); if (!informUsers) { continue; } await slackIntegration.SendDirectMessage(verificationResult.User, verificationResult.Errors); await slackIntegration.SendDirectMessage(adminUser, verificationResult.Errors); } var validationReport = new ValidationReport(usersWithIncompleteProfiles.ToArray()); await faceWhitelist.UploadReport(validationReport); return(validationReport.ToString()); } await slackIntegration.SendDirectMessage(adminUser, await ValidateAllProfiles()); }
async Task ValidateAllProfiles(bool informUsers = false) { if (informUsers) { await slackIntegration.SendDirectMessage(adminUserId, "Notifying all users"); } else { await slackIntegration.SendDirectMessage(adminUserId, "Validating all users"); } var usersWithIncompleteProfiles = new List <ProfileValidationResult>(); foreach (var user in await slackIntegration.GetAllUsers()) { var verificationResult = slackProfileValidator.ValidateProfile(user); if (verificationResult.IsValid) { continue; } usersWithIncompleteProfiles.Add(verificationResult); if (!informUsers) { continue; } await slackIntegration.SendDirectMessage(verificationResult.UserId, verificationResult.Errors); await slackIntegration.SendDirectMessage(adminUserId, verificationResult.Errors); } var messageToOwner = usersWithIncompleteProfiles.Count == 0 ? "No profiles contain errors :)" : $"{usersWithIncompleteProfiles.Count} users have bad profiles:{Environment.NewLine}{String.Join(", ", usersWithIncompleteProfiles.Select(error => $"<@{error.UserId}>"))}"; await slackIntegration.SendDirectMessage(adminUserId, messageToOwner); }