and more...

This commit is contained in:
tsmethurst 2021-07-02 13:30:06 +02:00
commit 72a2bef878

View file

@ -27,14 +27,8 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
) )
func (p *processor) Delete(account *gtsmodel.Account, deletedBy string) error { // Delete handles the complete deletion of an account.
l := p.log.WithFields(logrus.Fields{ //
"func": "Delete",
"username": account.Username,
})
l.Debug("beginning account delete process")
// TODO in this function: // TODO in this function:
// 1. Delete account's application(s), clients, and oauth tokens // 1. Delete account's application(s), clients, and oauth tokens
// 2. Delete account's blocks // 2. Delete account's blocks
@ -54,6 +48,13 @@ func (p *processor) Delete(account *gtsmodel.Account, deletedBy string) error {
// 16. Delete account's user // 16. Delete account's user
// 17. Delete account's timeline // 17. Delete account's timeline
// 18. Delete account itself // 18. Delete account itself
func (p *processor) Delete(account *gtsmodel.Account, deletedBy string) error {
l := p.log.WithFields(logrus.Fields{
"func": "Delete",
"username": account.Username,
})
l.Debug("beginning account delete process")
// 1. Delete account's application(s), clients, and oauth tokens // 1. Delete account's application(s), clients, and oauth tokens
// we only need to do this step for local account since remote ones won't have any tokens or applications on our server // we only need to do this step for local account since remote ones won't have any tokens or applications on our server
@ -169,6 +170,34 @@ selectStatusesLoop:
l.Errorf("error deleting notifications created by account: %s", err) l.Errorf("error deleting notifications created by account: %s", err)
} }
// 11. Delete account's bookmarks
if err := p.db.DeleteWhere([]db.Where{{Key: "account_id", Value: account.ID}}, &[]*gtsmodel.StatusBookmark{}); err != nil {
l.Errorf("error deleting bookmarks created by account: %s", err)
}
// 12. Delete account's faves
if err := p.db.DeleteWhere([]db.Where{{Key: "account_id", Value: account.ID}}, &[]*gtsmodel.StatusFave{}); err != nil {
l.Errorf("error deleting faves created by account: %s", err)
}
// 13. Delete account's mutes
if err := p.db.DeleteWhere([]db.Where{{Key: "account_id", Value: account.ID}}, &[]*gtsmodel.StatusMute{}); err != nil {
l.Errorf("error deleting status mutes created by account: %s", err)
}
// 14. Delete account's streams
// 15. Delete account's tags
// TODO
// 16. Delete account's user
if err := p.db.DeleteWhere([]db.Where{{Key: "account_id", Value: account.ID}}, &gtsmodel.User{}); err != nil {
return err
}
// 17. Delete account's timeline
// 18. Delete account itself
// to prevent the account being created again, set all these fields and update it in the db // to prevent the account being created again, set all these fields and update it in the db
// the account won't actually be *removed* from the database but it will be set to just a stub // the account won't actually be *removed* from the database but it will be set to just a stub