-
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
Handle account data removal (PSG-865, PSG-867) #7740
Conversation
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.
Thanks. Some feedback. OOI in the context of which feature are you implementing this MSC?
* @param roomId the room id | ||
* @param type the type | ||
*/ | ||
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_MEDIA_PROXY_UNSTABLE + "org.matrix.msc3391/user/{userId}/rooms/{roomId}/account_data/{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.
Error in the path:
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_MEDIA_PROXY_UNSTABLE + "org.matrix.msc3391/user/{userId}/rooms/{roomId}/account_data/{type}") | |
@DELETE(NetworkConstants.URI_API_PREFIX_PATH_UNSTABLE + "org.matrix.msc3391/user/{userId}/rooms/{roomId}/account_data/{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.
Ups, good catch. Done.
UserAccountDataTypes.TYPE_IGNORED_USER_LIST -> handleIgnoredUsers(realm, event) | ||
UserAccountDataTypes.TYPE_BREADCRUMBS -> handleBreadcrumbs(realm, event) | ||
if (event.content.isEmpty()) { | ||
UserAccountDataEntity.delete(realm, event.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.
Should we do some treatment on specific Account data as per the when
block in the else
block below?
So I would keep the existing code, and move the removal from DB to the handleGenericAccountData()
method.
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.
Done. That was also my initial intention. We can trust all when
cases check the content.
@@ -36,4 +37,16 @@ internal interface AccountDataAPI { | |||
@Path("type") type: String, | |||
@Body params: Any | |||
) | |||
|
|||
/** | |||
* Remove an account_data for the client. |
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 a bit better, but we may found better.
* Remove an account_data for the client. | |
* Remove an account_data for the user. |
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 agree, done.
} else if (eventType == RoomAccountDataTypes.EVENT_TYPE_FULLY_READ) { | ||
val content = event.getClearContent().toModel<FullyReadContent>() | ||
roomFullyReadHandler.handle(realm, roomId, content) | ||
} |
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.
Same remark about dealing with specific room account data event.
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.
Done.
We started to store device information in account data and we need to delete it when session is logged out / deleted. Otherwise they will live in backend forever. |
@@ -256,8 +257,14 @@ internal class UserAccountDataSyncHandler @Inject constructor( | |||
.equalTo(UserAccountDataEntityFields.TYPE, type) | |||
.findFirst() | |||
if (existing != null) { | |||
// Update current value | |||
existing.contentStr = ContentMapper.map(content) | |||
if (content.isNullOrEmpty()) { |
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.
Still not good to me. If the account data does not exist yet, it will be added to the DB, and we want to remove it.
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.
Oh, right. Please check my last commit.
@@ -58,7 +59,13 @@ internal class RoomSyncAccountDataHandler @Inject constructor( | |||
private fun handleGeneric(roomEntity: RoomEntity, content: JsonDict?, eventType: String) { | |||
val existing = roomEntity.accountData.where().equalTo(RoomAccountDataEntityFields.TYPE, eventType).findFirst() | |||
if (existing != null) { | |||
existing.contentStr = ContentMapper.map(content) | |||
if (content.isNullOrEmpty()) { |
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.
Same remark. Please reorder your if
statements.
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.
Done.
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.
Perfect, thanks. Maybe squash and merge to avoid noisy git history.
SonarCloud Quality Gate failed. |
Type of change
Content
Synapse will start to support deleting account data events. If a client removes an account data event then it will be reported in sync response with an empty content
{}
. This PR adds delete endpoints (will be used in next PR) and also handles them in the sync response.Motivation and context
Implement MSC-3391
Screenshots / GIFs
Tests
Tested devices
Checklist