Repository navigation
feat: Expose homeserver capabilities - #6371
Conversation
Merging this PR will degrade performance by 49.78%
Performance Changes
Comparing |
9e1e6c9 to
e7f4923
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6371 +/- ##
==========================================
- Coverage 89.85% 89.82% -0.03%
==========================================
Files 376 377 +1
Lines 103102 103253 +151
Branches 103102 103253 +151
==========================================
+ Hits 92644 92749 +105
- Misses 6889 6917 +28
- Partials 3569 3587 +18 ☔ View full report in Codecov by Sentry. |
a8d412a to
92ec293
Compare
| /// Forces a refresh of the cached value using the `/capabilities` endpoint. | ||
| pub async fn refresh(&self) -> crate::Result<()> { | ||
| self.get_and_cache_remote_capabilities().await?; | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
Instead of adding a TtlCache or some other wrapper, that has proven problematic in the past, I thought we may want to just add a method we can call whenever we think these values should be reloaded, and we can decide when that time is best in the implementing clients.
Hywan
left a comment
There was a problem hiding this comment.
It looks great! Thank you! I've added a couple of feedback but no blocker.
| .allowed | ||
| .unwrap_or_default() | ||
| .into_iter() | ||
| .map(|f| f.to_string()) |
There was a problem hiding this comment.
.map(ToString::to_string) should work too.
There was a problem hiding this comment.
Ah, it does work if I use .iter() instead of .into_iter(). I tried using .map(ToString::to_string) at first and I didn't understand the error message (which I now realised was 'this expects a reference, not an owned value').
| .disallowed | ||
| .unwrap_or_default() | ||
| .into_iter() | ||
| .map(|f| f.to_string()) |
There was a problem hiding this comment.
.map(ToString::to_string) should work too.
Does this mean the PR should be approved? 😅 |
This extracts the `/capabilities` logic to its own `HomeserverCapabilities` component in the SDK that can be manually asked to fetch, cache locally and return these capabilities.
895d20a to
7fda103
Compare
Implements #6379.
This creates a new
HomeserverCapabilitieswrapper that handles the fetching, caching, loading cached values and refreshing them, also giving you a method to check every capability.This wrapper is also exposed in the FFI layer so clients using the bindings can use them.
CHANGELOG.mdfiles.Signed-off-by: