Add device endpoints.
This commit is contained in:
parent
d749f7ebc1
commit
523e58a801
@ -19,4 +19,4 @@ Improvements:
|
||||
* Add `contains_url` to `r0::filter::RoomEventFilter` (introduced upstream in r0.3.0)
|
||||
* Update `r0::account::change_password` from r0.3.0 to r0.6.0
|
||||
* Add optional `auth` field
|
||||
* Add `r0::device::delete_devices` (introduced upstream in r0.4.0)
|
||||
* Add `r0::device` endpoint
|
||||
|
@ -1,3 +1,24 @@
|
||||
//! Endpoints for managing devices.
|
||||
|
||||
pub mod delete_devices;
|
||||
use ruma_identifiers::DeviceId;
|
||||
use js_int::UInt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod bulk_delete_devices;
|
||||
pub mod get_device;
|
||||
pub mod get_devices;
|
||||
pub mod set_device;
|
||||
pub mod delete_device;
|
||||
|
||||
/// Information about a registered device.
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
|
||||
pub struct Device {
|
||||
/// Device ID
|
||||
pub device_id: DeviceId,
|
||||
/// Public display name of the device.
|
||||
pub display_name: Option<String>,
|
||||
/// Most recently seen IP address of the session.
|
||||
pub ip: Option<String>,
|
||||
/// Unix timestamp that the session was last active.
|
||||
pub last_seen: Option<UInt>,
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ use ruma_api::ruma_api;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Delete specified devices",
|
||||
description: "Delete specified devices.",
|
||||
method: POST,
|
||||
path: "/_matrix/client/r0/delete_devices",
|
||||
name: "delete_devices",
|
||||
name: "bulk_delete_devices",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
25
src/r0/device/delete_device.rs
Normal file
25
src/r0/device/delete_device.rs
Normal file
@ -0,0 +1,25 @@
|
||||
//! [DELETE /_matrix/client/r0/devices/{deviceId}](https://matrix.org/docs/spec/client_server/r0.6.0#delete-matrix-client-r0-devices-deviceid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::DeviceId;
|
||||
use crate::r0::account::AuthenticationData;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Delete a device for authenticated user.",
|
||||
method: DELETE,
|
||||
name: "delete_device",
|
||||
path: "/_matrix/client/r0/devices/:device_id",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
#[ruma_api(path)]
|
||||
device_id: DeviceId,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
auth: Option<AuthenticationData>,
|
||||
}
|
||||
|
||||
response {}
|
||||
}
|
25
src/r0/device/get_device.rs
Normal file
25
src/r0/device/get_device.rs
Normal file
@ -0,0 +1,25 @@
|
||||
//! [GET /_matrix/client/r0/devices/{deviceId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices-deviceid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::DeviceId;
|
||||
use super::Device;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Get a device for authenticated user.",
|
||||
method: GET,
|
||||
name: "get_device",
|
||||
path: "/_matrix/client/r0/devices/:device_id",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
#[ruma_api(path)]
|
||||
device_id: DeviceId,
|
||||
}
|
||||
|
||||
response {
|
||||
device: Device,
|
||||
}
|
||||
}
|
21
src/r0/device/get_devices.rs
Normal file
21
src/r0/device/get_devices.rs
Normal file
@ -0,0 +1,21 @@
|
||||
//! [GET /_matrix/client/r0/devices](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use super::Device;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Get registered devices for authenticated user.",
|
||||
method: GET,
|
||||
name: "get_devices",
|
||||
path: "/_matrix/client/r0/devices",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {}
|
||||
|
||||
response {
|
||||
devices: Vec<Device>
|
||||
}
|
||||
}
|
24
src/r0/device/set_device.rs
Normal file
24
src/r0/device/set_device.rs
Normal file
@ -0,0 +1,24 @@
|
||||
//! [PUT /_matrix/client/r0/devices/{deviceId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-devices-deviceid)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::DeviceId;
|
||||
|
||||
ruma_api! {
|
||||
metadata {
|
||||
description: "Update metadata for a device.",
|
||||
method: PUT,
|
||||
name: "set_device",
|
||||
path: "/_matrix/client/r0/devices/:device_id",
|
||||
rate_limited: false,
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
request {
|
||||
#[ruma_api(path)]
|
||||
device_id: DeviceId,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
display_name: Option<String>,
|
||||
}
|
||||
|
||||
response {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user