Skip to content

Conversation

@MatMaul
Copy link
Contributor

@MatMaul MatMaul commented Dec 2, 2025

Add memberships endpoint to the admin API. This is useful for forensics and T&S purpose.

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)

@MatMaul MatMaul force-pushed the admin-left-rooms branch 2 times, most recently from b5263c3 to f845b3f Compare December 2, 2025 12:59
@MatMaul MatMaul changed the title Add left_rooms admin API Add memberships admin API Dec 2, 2025
@github-actions github-actions bot deployed to PR Documentation Preview December 2, 2025 13:17 Active

return frozenset(room_ids)

async def get_memberships_for_user(self, user_id: str) -> dict[str, str]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want a cache here ? if yes we also need to add invalidation.
I didn't do it because it should be used not that often since it is only used by the admin API (for now).

return dict(rows)

@cached(max_entries=500000, iterable=True)
async def get_rooms_for_user(self, user_id: str) -> frozenset[str]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we change this to use get_memberships_for_user ? it will pull quite a lot more data and this is used in a lot of places so I am tempted to not touch it to not affect performances.

Copy link
Contributor Author

@MatMaul MatMaul Dec 2, 2025

Choose a reason for hiding this comment

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

Another option would be to make get_memberships_for_user take a list of membership we are interested in, with empty meaning everything.
In this case the perf would be basically the same (with a cache on get_memberships_for_user and not on get_rooms_for_user anymore).

@MatMaul MatMaul marked this pull request as ready for review December 2, 2025 13:38
@MatMaul MatMaul requested a review from a team as a code owner December 2, 2025 13:38
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.

1 participant