fix notification
This commit is contained in:
parent
9a6971c6bc
commit
8840d1007c
|
@ -105,7 +105,7 @@ namespace BirdsiteLive.Domain
|
|||
return result;
|
||||
}
|
||||
|
||||
public async Task MigrateAccountAsync(ValidatedFediverseUser validatedUser, string acct)
|
||||
public async Task MigrateAccountAsync(ValidatedFediverseUser validatedUser, string acct, bool notify)
|
||||
{
|
||||
// Apply moved to
|
||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
||||
|
@ -120,12 +120,15 @@ namespace BirdsiteLive.Domain
|
|||
await _twitterUserDal.UpdateTwitterUserAsync(twitterAccount);
|
||||
|
||||
// Notify Followers
|
||||
if (notify)
|
||||
{
|
||||
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
||||
This bot has been disabled by it's original owner.<br/>
|
||||
It has been redirected to {validatedUser.FediverseAcct}.
|
||||
</p>";
|
||||
NotifyFollowers(acct, twitterAccount, 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
|
||||
var twitterAccount = await _twitterUserDal.GetTwitterUserAsync(acct);
|
||||
|
@ -184,11 +187,14 @@ namespace BirdsiteLive.Domain
|
|||
|
||||
|
||||
// Notify Followers
|
||||
if (notify)
|
||||
{
|
||||
var message = $@"<p>[BSL MIRROR SERVICE NOTIFICATION]<br/>
|
||||
This bot has been deleted by it's original owner.<br/>
|
||||
</p>";
|
||||
NotifyFollowers(acct, twitterAccount, message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task TriggerRemoteMigrationAsync(string id, string tweetid, string handle)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace BirdsiteLive.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id);
|
||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id, true);
|
||||
await _migrationService.TriggerRemoteMigrationAsync(id, tweetid, handle);
|
||||
data.MigrationSuccess = true;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace BirdsiteLive.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
await _migrationService.DeleteAccountAsync(id);
|
||||
await _migrationService.DeleteAccountAsync(id, true);
|
||||
await _migrationService.TriggerRemoteDeleteAsync(id, tweetid);
|
||||
data.MigrationSuccess = true;
|
||||
}
|
||||
|
@ -148,22 +148,30 @@ namespace BirdsiteLive.Controllers
|
|||
public async Task<IActionResult> RemoteMigrateMove(string id, string tweetid, string 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)
|
||||
{
|
||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id);
|
||||
await _migrationService.MigrateAccountAsync(fediverseUserValidation, id, false);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
return StatusCode(500);
|
||||
return StatusCode(400);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue