Skip to content

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

Merged

Conversation

uhoreg
Copy link
Member

@uhoreg uhoreg commented Mar 18, 2025

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

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

@uhoreg uhoreg marked this pull request as ready for review March 18, 2025 20:04
@uhoreg uhoreg requested a review from a team as a code owner March 18, 2025 20:04
Copy link
Member

@anoadragon453 anoadragon453 left a 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?

else:
self.assertNotIn("dehydrated", d)

self.assertEqual(True, found_dehydrated)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertEqual(True, found_dehydrated)
self.assertTrue(found_dehydrated)

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"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.assertEqual(True, d.get("dehydrated"))
self.assertTrue(d.get("dehydrated"))

self.assertEqual(True, d.get("dehydrated"))
found_dehydrated = True
else:
self.assertNotIn("dehydrated", d)
Copy link
Member

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.

Suggested change
self.assertNotIn("dehydrated", d)
# Either the field is not present, or set to False
self.assertFalse(d["dehydrated])

Comment on lines 153 to 154
if device["device_id"] == dehydrated_device_id:
device["dehydrated"] = True
Copy link
Member

@anoadragon453 anoadragon453 Apr 28, 2025

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?

Suggested change
if device["device_id"] == dehydrated_device_id:
device["dehydrated"] = True
is_dehydrated = device["device_id"] == dehydrated_device_id
device["dehydrated"] = is_dehydrated

@github-actions github-actions bot deployed to PR Documentation Preview May 12, 2025 21:25 Active
@uhoreg uhoreg requested a review from anoadragon453 May 27, 2025 13:06
@uhoreg
Copy link
Member Author

uhoreg commented May 27, 2025

Looks like I forgot to re-request review 🤦

Copy link
Member

@anoadragon453 anoadragon453 left a 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!

@anoadragon453 anoadragon453 merged commit 2436512 into element-hq:develop May 28, 2025
10 checks passed
@github-actions github-actions bot deployed to PR Documentation Preview May 28, 2025 11:21 Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants