various logic fixes
This commit is contained in:
parent
d5a71bbaa6
commit
c910edc6b3
|
@ -65,13 +65,22 @@ namespace BirdsiteLive.Domain
|
||||||
throw new Exception($"Tweet not published by @{acct}");
|
throw new Exception($"Tweet not published by @{acct}");
|
||||||
|
|
||||||
if (!tweet.MessageContent.Contains(code))
|
if (!tweet.MessageContent.Contains(code))
|
||||||
throw new Exception("Tweet don't have migration code");
|
{
|
||||||
|
var message = "Tweet don't have migration code";
|
||||||
|
if (type == MigrationTypeEnum.Deletion)
|
||||||
|
message = "Tweet don't have deletion code";
|
||||||
|
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long ExtractedTweetId(string tweetId)
|
private long ExtractedTweetId(string tweetId)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(tweetId))
|
||||||
|
throw new ArgumentException("No provided Tweet ID");
|
||||||
|
|
||||||
long castedId;
|
long castedId;
|
||||||
if (long.TryParse(tweetId, out castedId))
|
if (long.TryParse(tweetId, out castedId))
|
||||||
return castedId;
|
return castedId;
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace BirdsiteLive.Twitter.Extractors
|
||||||
IsThread = tweet.InReplyToUserId != null && tweet.InReplyToUserId == tweet.CreatedBy.Id,
|
IsThread = tweet.InReplyToUserId != null && tweet.InReplyToUserId == tweet.CreatedBy.Id,
|
||||||
IsRetweet = tweet.IsRetweet || tweet.QuotedStatusId != null,
|
IsRetweet = tweet.IsRetweet || tweet.QuotedStatusId != null,
|
||||||
RetweetUrl = ExtractRetweetUrl(tweet),
|
RetweetUrl = ExtractRetweetUrl(tweet),
|
||||||
CreatorName = tweet.CreatedBy.Name
|
CreatorName = tweet.CreatedBy.UserIdentifier.ScreenName
|
||||||
};
|
};
|
||||||
|
|
||||||
return extractedTweet;
|
return extractedTweet;
|
||||||
|
|
|
@ -71,12 +71,14 @@ namespace BirdsiteLive.Controllers
|
||||||
|
|
||||||
//Verify can be migrated
|
//Verify can be migrated
|
||||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(id);
|
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(id);
|
||||||
if (twitterAccount.Deleted)
|
if (twitterAccount != null && twitterAccount.Deleted)
|
||||||
{
|
{
|
||||||
data.ErrorMessage = "This account has been deleted, it can't be migrated";
|
data.ErrorMessage = "This account has been deleted, it can't be migrated";
|
||||||
return View("Index", data);
|
return View("Index", data);
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(twitterAccount.MovedTo) || !string.IsNullOrWhiteSpace(twitterAccount.MovedToAcct))
|
if (twitterAccount != null &&
|
||||||
|
(!string.IsNullOrWhiteSpace(twitterAccount.MovedTo)
|
||||||
|
|| !string.IsNullOrWhiteSpace(twitterAccount.MovedToAcct)))
|
||||||
{
|
{
|
||||||
data.ErrorMessage = "This account has been moved already, it can't be migrated again";
|
data.ErrorMessage = "This account has been moved already, it can't be migrated again";
|
||||||
return View("Index", data);
|
return View("Index", data);
|
||||||
|
@ -118,12 +120,12 @@ namespace BirdsiteLive.Controllers
|
||||||
[Route("/migration/delete/{id}")]
|
[Route("/migration/delete/{id}")]
|
||||||
public async Task<IActionResult> MigrateDelete(string id, string tweetid)
|
public async Task<IActionResult> MigrateDelete(string id, string tweetid)
|
||||||
{
|
{
|
||||||
var migrationCode = _migrationService.GetMigrationCode(id);
|
var deletionCode = _migrationService.GetDeletionCode(id);
|
||||||
|
|
||||||
var data = new MigrationData()
|
var data = new MigrationData()
|
||||||
{
|
{
|
||||||
Acct = id,
|
Acct = id,
|
||||||
MigrationCode = migrationCode,
|
MigrationCode = deletionCode,
|
||||||
|
|
||||||
IsTweetProvided = !string.IsNullOrWhiteSpace(tweetid),
|
IsTweetProvided = !string.IsNullOrWhiteSpace(tweetid),
|
||||||
|
|
||||||
|
@ -132,16 +134,16 @@ namespace BirdsiteLive.Controllers
|
||||||
|
|
||||||
//Verify can be deleted
|
//Verify can be deleted
|
||||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(id);
|
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(id);
|
||||||
if (twitterAccount.Deleted)
|
if (twitterAccount != null && twitterAccount.Deleted)
|
||||||
{
|
{
|
||||||
data.ErrorMessage = "This account has been deleted, it can't be deleted again";
|
data.ErrorMessage = "This account has been deleted, it can't be deleted again";
|
||||||
return View("Index", data);
|
return View("Delete", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start deletion
|
// Start deletion
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var isTweetValid = _migrationService.ValidateTweet(id, tweetid, MigrationTypeEnum.Migration);
|
var isTweetValid = _migrationService.ValidateTweet(id, tweetid, MigrationTypeEnum.Deletion);
|
||||||
data.IsTweetValid = isTweetValid;
|
data.IsTweetValid = isTweetValid;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -164,7 +166,7 @@ namespace BirdsiteLive.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("Index", data);
|
return View("Delete", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|
Loading…
Reference in New Issue