-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete unused client information from account data (PSG-871) #7754
Delete unused client information from account data (PSG-871) #7754
Conversation
) | ||
} | ||
|
||
internal class DefaultDeleteUserAccountDataTask @Inject constructor( |
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.
We could add unit tests on this class.
return realmSessionProvider.withRealm { realm -> | ||
realm | ||
.where(UserAccountDataEntity::class.java) | ||
.contains(UserAccountDataEntityFields.TYPE, type) |
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.
I think we should use beginsWith
instead of contains
if we want to reflect the method name.
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo | ||
import javax.inject.Inject | ||
|
||
class DeleteUnusedClientInformationUseCase @Inject constructor( |
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.
I think we should put this class in the package core.session.clientinfo
with the other classes about MatrixClientInfo
.
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.settings.devices.v2 |
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.
This test class should also be moved to core.session.clientinfo
package.
private val activeSessionHolder: ActiveSessionHolder, | ||
) { | ||
|
||
suspend fun execute(deviceInfoList: List<DeviceInfo>) { |
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.
Maybe we should wrap the implementation using a runCatching
and return a Result
to avoid having the parent coroutine scope to be cancelled in case of network error (e.g. delete api not supported)?
@@ -102,6 +105,9 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor( | |||
) { cryptoList, infoList, pInfo -> | |||
// Timber.v("## Detector trigger ${cryptoList.map { "${it.deviceId} ${it.trustLevel}" }}") | |||
// Timber.v("## Detector trigger canCrossSign ${pInfo.get().selfSigned != null}") | |||
|
|||
deleteUnusedClientInformation(infoList) |
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.
I guess we should add a unit test on this ViewModel
to cover this use case.
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.
I have added some small comments.
Can you also fill up the PR description and add a changelog entry?
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.
I didn't test it but LGTM! Thanks for the updates!
Kudos, SonarCloud Quality Gate passed! |
Type of change
Content
With new session manager implementation we started to store information of user devices in account data. If user logouts / delete a session we need to delete the corresponding client information to keep the account data as clean as possible. Backend has now a new endpoint to be able to delete account data events. This PR implements this feature.
Motivation and context
Implement MSC-3391
Screenshots / GIFs
Tests
account_data/io.element.matrix_client_information.DEVICE
Tested devices
Checklist