arminius_lib_federation_output_service_messages/
command.rs1use std::collections::BTreeMap;
7
8use arminius_lib_message_bus::Command;
9use arminius_lib_user_keys::{identity_keys::RawUserKeys, one_time_keys::FederatedOneTimeKeys};
10use ruma::{
11 OneTimeKeyAlgorithm, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedUserId,
12 RoomVersionId,
13 api::federation::{
14 discovery::ServerSigningKeys,
15 membership::{RawStrippedState, create_join_event::v2::RoomState},
16 },
17};
18use serde::{Deserialize, Serialize};
19use serde_json::value::RawValue;
20
21use crate::error::MiscRequestError;
22
23pub const COMMAND_SUBJECT_FILTER: &str = "federation-output-service.commands.>";
29
30#[derive(Debug, Clone, Serialize, Deserialize, Command)]
32#[subject(name = "federation-output-service.commands.discover_server_keys", version = "1")]
33#[command(reply = Result<ServerSigningKeys, MiscRequestError>)]
34pub struct DiscoverServerKeysCommand {
35 pub destination: OwnedServerName,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct MakeJoinReply {
45 pub room_version: Option<RoomVersionId>,
47 pub event: Box<RawValue>,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize, Command)]
53#[subject(name = "federation-output-service.commands.make_join", version = "1")]
54#[command(reply = Result<MakeJoinReply, MiscRequestError>)]
55pub struct MakeJoinCommand {
56 pub destination: OwnedServerName,
58 pub room_id: OwnedRoomId,
60 pub user_id: OwnedUserId,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize, Command)]
66#[subject(name = "federation-output-service.commands.send_join", version = "1")]
67#[command(reply = Result<RoomState, MiscRequestError>)]
68pub struct SendJoinCommand {
69 pub destination: OwnedServerName,
71 pub room_id: OwnedRoomId,
73 pub event_id: OwnedEventId,
75 pub pdu: Box<RawValue>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize, Command)]
85#[subject(name = "federation-output-service.commands.send_invite", version = "1")]
86#[command(reply = Result<Box<RawValue>, MiscRequestError>)]
87pub struct SendInviteCommand {
88 pub destination: OwnedServerName,
90 pub room_id: OwnedRoomId,
92 pub event_id: OwnedEventId,
94 pub room_version: RoomVersionId,
96 pub pdu: Box<RawValue>,
98 pub invite_room_state: Vec<RawStrippedState>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize, Command)]
104#[subject(name = "federation-output-service.commands.get_profile", version = "1")]
105#[command(reply = Result<serde_json::Value, MiscRequestError>)]
106pub struct GetProfileCommand {
107 pub destination: OwnedServerName,
109 pub user_id: OwnedUserId,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize, Command)]
124#[subject(name = "federation-output-service.commands.claim_one_time_keys", version = "1")]
125#[command(reply = Result<FederatedOneTimeKeys, MiscRequestError>, delivery = at_most_once)]
126pub struct ClaimOneTimeKeysCommand {
127 pub destination: OwnedServerName,
129 pub one_time_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>>,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize, Command)]
135#[subject(name = "federation-output-service.commands.fetch_user_keys", version = "1")]
136#[command(reply = Result<RawUserKeys, MiscRequestError>)]
137pub struct FetchUserKeysCommand {
138 pub destination: OwnedServerName,
140 pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, Command)]
146#[subject(name = "federation-output-service.commands.retrieve_event", version = "1")]
147#[command(reply = Result<serde_json::Value, MiscRequestError>)]
148pub struct RetrieveEventCommand {
149 pub destination: OwnedServerName,
151 pub event_id: OwnedEventId,
153}