-
Notifications
You must be signed in to change notification settings - Fork 327
Mark dehydrated devices in admin get devices endpoint #18252
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
Mark dehydrated devices in admin get devices endpoint #18252
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.
LGTM overall! Apologies for the long delay on a review :(
Thanks for adding a test! Could you please update the relevant documentation to include the new field as well?
tests/rest/admin/test_device.py
Outdated
else: | ||
self.assertNotIn("dehydrated", d) | ||
|
||
self.assertEqual(True, found_dehydrated) |
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.
self.assertEqual(True, found_dehydrated) | |
self.assertTrue(found_dehydrated) |
tests/rest/admin/test_device.py
Outdated
for d in channel.json_body["devices"]: | ||
self.assertIn("user_id", d) | ||
self.assertIn("device_id", d) | ||
self.assertIn("display_name", d) | ||
self.assertIn("last_seen_ip", d) | ||
self.assertIn("last_seen_ts", d) | ||
if d["device_id"] == "dehydrated_device": | ||
self.assertEqual(True, d.get("dehydrated")) |
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.
self.assertEqual(True, d.get("dehydrated")) | |
self.assertTrue(d.get("dehydrated")) |
tests/rest/admin/test_device.py
Outdated
self.assertEqual(True, d.get("dehydrated")) | ||
found_dehydrated = True | ||
else: | ||
self.assertNotIn("dehydrated", d) |
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.
To align with the suggestion above.
self.assertNotIn("dehydrated", d) | |
# Either the field is not present, or set to False | |
self.assertFalse(d["dehydrated]) |
synapse/rest/admin/devices.py
Outdated
if device["device_id"] == dehydrated_device_id: | ||
device["dehydrated"] = True |
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 it might be nicer from an Admin API standpoint if the dehydrated
field was always present?
if device["device_id"] == dehydrated_device_id: | |
device["dehydrated"] = True | |
is_dehydrated = device["device_id"] == dehydrated_device_id | |
device["dehydrated"] = is_dehydrated |
Looks like I forgot to re-request review 🤦 |
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.
Ah, yep! It will get lost otherwise ❤️
Thanks for updating the PR. This now LGTM!
Mark the dehydrated device. This is needed for dehydrated devices and MAS, because MAS tries to delete all the devices that it doesn't know about, so it needs to know about the dehydrated device so that it can ignore it.
Companion PR: element-hq/matrix-authentication-service#4268
Part of a fix to element-hq/element-meta#2784
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)