Commit dab31fa458

dab31fa4581645528f91d06d50dd902520d09b9f

parent: 3091d7a838

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-27 17:37 UTC
committer: <strk@kbt.io>

fix: delete single Matrix devices via device endpoint

Layout: unified · split

src/connection.rs +16
@@ -22,6 +22,7 @@ use matrix_sdk::{
2222 ruma::{
2323 api::client::{
2424 device::{
25 delete_device::{self, v3::Response as DeleteDeviceResponse},
2526 delete_devices::v3::Response as DeleteDevicesResponse,
2627 get_devices::v3::Response as DevicesResponse,
2728 },
@@ -230,6 +231,21 @@ impl Connection {
230231 .await?)
231232 }
232233
234 pub async fn delete_device(
235 &self,
236 device: OwnedDeviceId,
237 auth_info: Option<InteractiveAuthInfo>,
238 ) -> MatrixResult<DeleteDeviceResponse> {
239 let client = self.client().clone();
240 Ok(self
241 .spawn(async move {
242 let mut request = delete_device::v3::Request::new(device);
243 request.auth = auth_info.map(|info| info.as_auth_data());
244 client.send(request).await
245 })
246 .await?)
247 }
248
233249 /// Fetch historical messages for the given room.
234250 pub async fn room_messages(
235251 &self,
src/server.rs +12 −5
@@ -1279,7 +1279,17 @@ impl InnerServer {
12791279 };
12801280
12811281 if let Some(c) = self.connection() {
1282 match c.delete_devices(devices.clone(), None).await {
1282 let delete = |auth_info| async {
1283 if let [device] = devices.as_slice() {
1284 c.delete_device(device.clone(), auth_info).await.map(|_| ())
1285 } else {
1286 c.delete_devices(devices.clone(), auth_info)
1287 .await
1288 .map(|_| ())
1289 }
1290 };
1291
1292 match delete(None).await {
12831293 Ok(_) => print_success(),
12841294 Err(e) => {
12851295 if let Some(info) = e.as_uiaa_response() {
@@ -1292,10 +1302,7 @@ impl InnerServer {
12921302 }
12931303 };
12941304
1295 if let Err(e) = c
1296 .delete_devices(devices.clone(), Some(auth_info))
1297 .await
1298 {
1305 if let Err(e) = delete(Some(auth_info)).await {
12991306 print_fail(e);
13001307 } else {
13011308 print_success();