public async Task<ActionResult> DeleteAsync(string id, string notification)
{
Requires.NotNullOrEmpty(id, "id");
if (notification == null)
{
return await this.DeleteAsync(id);
}
Requires.NotNullOrEmpty(notification, "notification");
// The if check verifies that the notification URL is a blob that
// belongs to the id'd container, thus ensuring that one valid user
// can't delete another user's notifications.
var directory = this.InboxContainer.GetDirectoryReference(id);
if (directory.Uri.IsBaseOf(new Uri(notification, UriKind.Absolute)))
{
var blob = this.InboxContainer.GetBlockBlobReference(notification);
try
{
await blob.DeleteAsync();
}
catch (StorageException ex)
{
if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
{
return new HttpNotFoundResult(ex.Message);
}
throw;
}
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
}
else
{
return new HttpUnauthorizedResult("Notification URL does not match owner id.");
}
}