Files
kvitt/server/crates/kvitt-server/src/api/devices.rs
T
jacobh2 06f48ef9e9 M2a: server workspace, kvitt-domain, skeleton routes, OpenAPI match, Dockerfile
Cargo workspace (kvitt-domain, kvitt-server, kvitt-import), Rust 1.99.1 pinned.
kvitt-domain passes every Rust vector and adds next_occurrence_date (D-015).
kvitt-server: config, SQLite pool (WAL, §8.9 pragmas), migration 0001 identical to
the contract schema, error type for all 25 codes, auth extractor and protocol
layer, all 33 routes (E-1/E-2 implemented, the rest 501), utoipa document equal
to contracts/openapi.yaml, seams for M3/M4/M9, serve/migrate/healthcheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:30:20 +02:00

59 lines
2.0 KiB
Rust

//! Devices: E-15 list, E-16 revoke, E-17 push token (FR-3, SPEC §8.4).
//!
//! Registered and annotated by M2a; M3 owns this file and implements the handlers (until then 501
//! `not_implemented`).
use crate::api::{IdPath, not_implemented};
use crate::auth::AuthDevice;
use crate::error::AppError;
use crate::openapi::responses::{BadRequest, Conflict, Forbidden, NotFound};
use crate::wire::{DeviceList, PushTokenRequest, UuidSchema};
#[utoipa::path(
get,
path = "/devices",
operation_id = "listDevices",
summary = "E-15 List devices (admin all, member own)",
responses(
(status = 200, description = "Ordered by `created_at`, revoked devices included (with `revoked_at`).", body = DeviceList, content_type = "application/json; charset=utf-8"),
)
)]
pub async fn list_devices(_device: AuthDevice) -> AppError {
not_implemented()
}
#[utoipa::path(
delete,
path = "/devices/{device_id}",
operation_id = "revokeDevice",
summary = "E-16 Revoke a device",
description = "Revoking an already revoked device is 204. Admin any device except the current one; member own devices except the current one (SPEC §8.4).",
params(
("device_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
),
responses(
(status = 204, description = "Revoked."),
(status = 403, response = Forbidden),
(status = 404, response = NotFound),
(status = 409, response = Conflict),
)
)]
pub async fn revoke_device(_device: AuthDevice, IdPath(_device_id): IdPath) -> AppError {
not_implemented()
}
#[utoipa::path(
put,
path = "/devices/current/push-token",
operation_id = "putPushToken",
summary = "E-17 Set or clear this device's FCM token",
request_body(content = PushTokenRequest, content_type = "application/json; charset=utf-8"),
responses(
(status = 204, description = "Stored (or cleared)."),
(status = 400, response = BadRequest),
)
)]
pub async fn put_push_token(_device: AuthDevice) -> AppError {
not_implemented()
}