This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 678
Add evacuateUser
endpoint, use it when deactivating accounts
#2545
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ import ( | |
"github.com/matrix-org/dendrite/internal/pushrules" | ||
"github.com/matrix-org/dendrite/internal/sqlutil" | ||
keyapi "github.com/matrix-org/dendrite/keyserver/api" | ||
rsapi "github.com/matrix-org/dendrite/roomserver/api" | ||
"github.com/matrix-org/dendrite/setup/config" | ||
"github.com/matrix-org/dendrite/userapi/api" | ||
"github.com/matrix-org/dendrite/userapi/producers" | ||
|
@@ -49,6 +50,7 @@ type UserInternalAPI struct { | |
// AppServices is the list of all registered AS | ||
AppServices []config.ApplicationService | ||
KeyAPI keyapi.UserKeyAPI | ||
RSAPI rsapi.UserRoomserverAPI | ||
} | ||
|
||
func (a *UserInternalAPI) InputAccountData(ctx context.Context, req *api.InputAccountDataRequest, res *api.InputAccountDataResponse) error { | ||
|
@@ -452,6 +454,30 @@ func (a *UserInternalAPI) queryAppServiceToken(ctx context.Context, token, appSe | |
|
||
// PerformAccountDeactivation deactivates the user's account, removing all ability for the user to login again. | ||
func (a *UserInternalAPI) PerformAccountDeactivation(ctx context.Context, req *api.PerformAccountDeactivationRequest, res *api.PerformAccountDeactivationResponse) error { | ||
evacuateReq := &rsapi.PerformAdminEvacuateUserRequest{ | ||
UserID: fmt.Sprintf("@%s:%s", req.Localpart, a.ServerName), | ||
} | ||
evacuateRes := &rsapi.PerformAdminEvacuateUserResponse{} | ||
a.RSAPI.PerformAdminEvacuateUser(ctx, evacuateReq, evacuateRes) | ||
if err := evacuateRes.Error; err != nil { | ||
logrus.WithError(err).Errorf("Failed to evacuate user after account deactivation") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually before the account deactivation. So we probably want to move all this (evacuate, delete devices) after we successfully deactivated the account. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ordering here is a good point — initially, if the evacuation failed, the deactivation failed with it, so as to not leave the user with the impression that something had happened that actually hadn't. I'm now not so sure. Also yes, we should delete pushers. I'll add that too. |
||
} | ||
|
||
deviceReq := &api.PerformDeviceDeletionRequest{ | ||
UserID: fmt.Sprintf("@%s:%s", req.Localpart, a.ServerName), | ||
} | ||
deviceRes := &api.PerformDeviceDeletionResponse{} | ||
if err := a.PerformDeviceDeletion(ctx, deviceReq, deviceRes); err != nil { | ||
return err | ||
} | ||
|
||
pusherReq := &api.PerformPusherDeletionRequest{ | ||
Localpart: req.Localpart, | ||
} | ||
if err := a.PerformPusherDeletion(ctx, pusherReq, &struct{}{}); err != nil { | ||
return err | ||
} | ||
|
||
err := a.DB.DeactivateAccount(ctx, req.Localpart) | ||
res.AccountDeactivated = err == nil | ||
return err | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about invites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, I will include invites.