in code/Server/Common/Managers/CVSModerationManager.cs [602:730]
public async Task SubmitUserForModeration(
ProcessType processType,
string appHandle,
string moderationHandle,
string userHandle,
Uri callbackUri)
{
// if init has not yet been called, do it now.
if (this.initStarted == false)
{
await this.Init();
}
// if init is not yet done, wait for it to finish.
this.initDone.WaitOne();
// check input
if (string.IsNullOrWhiteSpace(appHandle))
{
throw new ArgumentNullException("appHandle");
}
if (string.IsNullOrWhiteSpace(moderationHandle))
{
throw new ArgumentNullException("moderationHandle");
}
if (string.IsNullOrWhiteSpace(userHandle))
{
throw new ArgumentNullException("userHandle");
}
if (callbackUri == null)
{
throw new ArgumentNullException("callbackUri");
}
// get the user profile content
IUserProfileEntity userProfileEntity = await this.usersManager.ReadUserProfile(userHandle, appHandle);
if (userProfileEntity == null || userProfileEntity.ReviewStatus == ReviewStatus.Banned)
{
// nothing more to do here; it has already been deleted or banned
this.log.LogInformation("User has already been deleted or banned for appHandle " + appHandle + " and moderationHandle " + moderationHandle);
return;
}
string text1 = userProfileEntity.FirstName;
string text2 = userProfileEntity.LastName;
string text3 = userProfileEntity.Bio;
var imageHandle = userProfileEntity.PhotoHandle;
Uri imageUri = null;
// check to see if the image exists in our blob storage
if (!string.IsNullOrWhiteSpace(imageHandle) && await this.blobsManager.ImageExists(imageHandle))
{
// enforce that the version of the image we submit to cvs meets
// certain format requirements
var newImageHandle = await this.EnforceCVSImageFormat(imageHandle);
imageUri = await this.blobsManager.ReadImageCdnUrl(newImageHandle);
if (imageUri == null)
{
this.log.LogInformation(string.Format("There is no image url to validate for image {0}.", newImageHandle));
return;
}
}
// skip if there's nothing to be submitted for review
if (string.IsNullOrWhiteSpace(text1) && string.IsNullOrWhiteSpace(text2) && string.IsNullOrWhiteSpace(text3) && imageUri == null)
{
// nothing we can do here since there is no content
this.log.LogInformation("The user profile is empty for appHandle " + appHandle + " and moderationHandle " + moderationHandle);
return;
}
// Build CVS request
CVSRequest cvsRequest = new CVSRequest(new Uri(this.cvsUrl), this.cvsKey);
CVSContent cvsContent = new CVSContent();
if (!string.IsNullOrWhiteSpace(text1))
{
cvsContent.AddText(text1);
}
if (!string.IsNullOrWhiteSpace(text2))
{
cvsContent.AddText(text2);
}
if (!string.IsNullOrWhiteSpace(text3))
{
cvsContent.AddText(text3);
}
if (imageUri != null)
{
cvsContent.AddImageUri(imageUri);
}
// submit to CVS
var jobId = await cvsRequest.SubmitAsyncJob(cvsContent, callbackUri);
var submissionTime = DateTime.UtcNow;
// store cvs transaction
await this.cvsTransactionStore.InsertTransaction(
StorageConsistencyMode.Strong,
moderationHandle,
appHandle,
ReportType.User,
submissionTime,
cvsContent.GetContentItemsAsJson(),
jobId,
callbackUri.ToString());
// add user moderation to the moderation store
// this is necessary as it records the user lookup information, which
// would be required when CVS posts results back with a moderation handle
await this.moderationStore.InsertModeration(
StorageConsistencyMode.Strong,
moderationHandle,
imageHandle,
ContentType.Unknown,
null,
userHandle,
appHandle,
ImageType.UserPhoto,
ModerationStatus.Pending,
submissionTime);
}