fix notification
This commit is contained in:
parent
9a6971c6bc
commit
8840d1007c
|
@ -105,7 +105,7 @@ namespace BirdsiteLive.Domain
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MigrateAccountAsync(ValidatedFediverseUser validatedUser, string acct)
|
public async Task MigrateAccountAsync(ValidatedFediverseUser validatedUser, string acct, bool notify)
|
||||||
{
|
{
|
||||||
// Apply moved to
|
// Apply moved to
|
||||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
||||||
|
@ -120,11 +120,14 @@ namespace BirdsiteLive.Domain
|
||||||
await _twitterUserDal.UpdateTwitterUserAsync(twitterAccount);
|
await _twitterUserDal.UpdateTwitterUserAsync(twitterAccount);
|
||||||
|
|
||||||
// Notify Followers
|
// Notify Followers
|
||||||
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
if (notify)
|
||||||
|
{
|
||||||
|
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
||||||
This bot has been disabled by it's original owner.<br/>
|
This bot has been disabled by it's original owner.<br/>
|
||||||
It has been redirected to {validatedUser.FediverseAcct}.
|
It has been redirected to {validatedUser.FediverseAcct}.
|
||||||
</p>";
|
</p>";
|
||||||
NotifyFollowers(acct, twitterAccount, message);
|
NotifyFollowers(acct, twitterAccount, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyFollowers(string acct, SyncTwitterUser twitterAccount, string message)
|
private void NotifyFollowers(string acct, SyncTwitterUser twitterAccount, string message)
|
||||||
|
@ -169,7 +172,7 @@ namespace BirdsiteLive.Domain
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAccountAsync(string acct)
|
public async Task DeleteAccountAsync(string acct, bool notify)
|
||||||
{
|
{
|
||||||
// Apply moved to
|
// Apply moved to
|
||||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
||||||
|
@ -184,10 +187,13 @@ namespace BirdsiteLive.Domain
|
||||||
|
|
||||||
|
|
||||||
// Notify Followers
|
// Notify Followers
|
||||||
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
if (notify)
|
||||||
|
{
|
||||||
|
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
||||||
This bot has been deleted by it's original owner.<br/>
|
This bot has been deleted by it's original owner.<br/>
|
||||||
</p>";
|
</p>";
|
||||||
NotifyFollowers(acct, twitterAccount, message);
|
NotifyFollowers(acct, twitterAccount, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task TriggerRemoteMigrationAsync(string id, string tweetid, string handle)
|
public async Task TriggerRemoteMigrationAsync(string id, string tweetid, string handle)
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace BirdsiteLive.Controllers
|
||||||
public async Task<IActionResult> MigrateMove(string id, string tweetid, string handle)
|
public async Task<IActionResult> MigrateMove(string id, string tweetid, string handle)
|
||||||
{
|
{
|
||||||
var migrationCode = _migrationService.GetMigrationCode(id);
|
var migrationCode = _migrationService.GetMigrationCode(id);
|
||||||
|
|
||||||
var data = new MigrationData()
|
var data = new MigrationData()
|
||||||
{
|
{
|
||||||
Acct = id,
|
Acct = id,
|
||||||
|
@ -80,12 +80,12 @@ namespace BirdsiteLive.Controllers
|
||||||
{
|
{
|
||||||
data.ErrorMessage = e.Message;
|
data.ErrorMessage = e.Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.IsAcctValid && data.IsTweetValid && fediverseUserValidation != null)
|
if (data.IsAcctValid && data.IsTweetValid && fediverseUserValidation != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id);
|
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id, true);
|
||||||
await _migrationService.TriggerRemoteMigrationAsync(id, tweetid, handle);
|
await _migrationService.TriggerRemoteMigrationAsync(id, tweetid, handle);
|
||||||
data.MigrationSuccess = true;
|
data.MigrationSuccess = true;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ namespace BirdsiteLive.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _migrationService.DeleteAccountAsync(id);
|
await _migrationService.DeleteAccountAsync(id, true);
|
||||||
await _migrationService.TriggerRemoteDeleteAsync(id, tweetid);
|
await _migrationService.TriggerRemoteDeleteAsync(id, tweetid);
|
||||||
data.MigrationSuccess = true;
|
data.MigrationSuccess = true;
|
||||||
}
|
}
|
||||||
|
@ -148,34 +148,42 @@ namespace BirdsiteLive.Controllers
|
||||||
public async Task<IActionResult> RemoteMigrateMove(string id, string tweetid, string handle)
|
public async Task<IActionResult> RemoteMigrateMove(string id, string tweetid, string handle)
|
||||||
{
|
{
|
||||||
var fediverseUserValidation = await _migrationService.ValidateFediverseAcctAsync(handle);
|
var fediverseUserValidation = await _migrationService.ValidateFediverseAcctAsync(handle);
|
||||||
var isTweetValid = _migrationService.ValidateTweet(id, tweetid, MigrationTypeEnum.Deletion);
|
var isTweetValid = _migrationService.ValidateTweet(id, tweetid, MigrationTypeEnum.Migration);
|
||||||
|
|
||||||
if (fediverseUserValidation.IsValid && isTweetValid)
|
if (fediverseUserValidation.IsValid && isTweetValid)
|
||||||
{
|
{
|
||||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id);
|
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id, false);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
return StatusCode(500);
|
return StatusCode(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/migration/delete/{id}/{tweetid}/{handle}")]
|
[Route("/migration/delete/{id}/{tweetid}/{handle}")]
|
||||||
public async Task<IActionResult> RemoteDeleteMove(string id, string tweetid, string handle)
|
public async Task<IActionResult> RemoteMigrateDelete(string id, string tweetid)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var isTweetValid = _migrationService.ValidateTweet(id, tweetid, MigrationTypeEnum.Deletion);
|
||||||
|
|
||||||
|
if (isTweetValid)
|
||||||
|
{
|
||||||
|
await _migrationService.DeleteAccountAsync(id, true);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
return StatusCode(400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MigrationData
|
public class MigrationData
|
||||||
{
|
{
|
||||||
public string Acct { get; set; }
|
public string Acct { get; set; }
|
||||||
|
|
||||||
public string FediverseAccount { get; set; }
|
public string FediverseAccount { get; set; }
|
||||||
public string TweetId { get; set; }
|
public string TweetId { get; set; }
|
||||||
|
|
||||||
public string MigrationCode { get; set; }
|
public string MigrationCode { get; set; }
|
||||||
|
|
||||||
public bool IsTweetProvided { get; set; }
|
public bool IsTweetProvided { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue