initialise capabilities with default constructor

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-01 00:00:22 -04:00 committed by June
parent e5735c81ed
commit beeacd4ef1

View file

@ -1,8 +1,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma::api::client::discovery::get_capabilities::{ use ruma::api::client::discovery::get_capabilities::{
self, Capabilities, ChangePasswordCapability, RoomVersionStability, RoomVersionsCapability, SetAvatarUrlCapability, self, Capabilities, RoomVersionStability, RoomVersionsCapability, ThirdPartyIdChangesCapability,
SetDisplayNameCapability, ThirdPartyIdChangesCapability,
}; };
use crate::{services, Result, Ruma}; use crate::{services, Result, Ruma};
@ -22,24 +21,12 @@ pub(crate) async fn get_capabilities_route(
available.insert(room_version.clone(), RoomVersionStability::Stable); available.insert(room_version.clone(), RoomVersionStability::Stable);
} }
let mut capabilities = Capabilities::new(); let mut capabilities = Capabilities::default();
capabilities.room_versions = RoomVersionsCapability { capabilities.room_versions = RoomVersionsCapability {
default: services().globals.default_room_version(), default: services().globals.default_room_version(),
available, available,
}; };
capabilities.change_password = ChangePasswordCapability {
enabled: true,
};
capabilities.set_avatar_url = SetAvatarUrlCapability {
enabled: true,
};
capabilities.set_displayname = SetDisplayNameCapability {
enabled: true,
};
// conduit does not implement 3PID stuff // conduit does not implement 3PID stuff
capabilities.thirdparty_id_changes = ThirdPartyIdChangesCapability { capabilities.thirdparty_id_changes = ThirdPartyIdChangesCapability {
enabled: false, enabled: false,