7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | // Copyright 2023 The Matrix.org Foundation C.I.C. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | // you may not use this file except in compliance with the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | // You may obtain a copy of the License at |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | // |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | // Unless required by applicable law or agreed to in writing, software |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | // See the License for the specific language governing permissions and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | // limitations under the License. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | use std::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | collections::{BTreeSet, HashMap}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | sync::Arc, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | time::Duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | use extension_trait::extension_trait; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | use matrix_sdk::attachment::{BaseAudioInfo, BaseFileInfo, BaseImageInfo, BaseVideoInfo}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | use ruma::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | KeyDerivationAlgorithm as RumaKeyDerivationAlgorithm, MatrixToUri, MatrixUri as RumaMatrixUri, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | OwnedRoomId, OwnedUserId, UInt, UserId, assign, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | events::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | GlobalAccountDataEvent as RumaGlobalAccountDataEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | GlobalAccountDataEventType as RumaGlobalAccountDataEventType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | RoomAccountDataEvent as RumaRoomAccountDataEvent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | RoomAccountDataEventType as RumaRoomAccountDataEventType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | direct::DirectEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | fully_read::FullyReadEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | identity_server::IdentityServerEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | ignored_user_list::{IgnoredUser as RumaIgnoredUser, IgnoredUserListEventContent}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 35 | location::AssetType as RumaAssetType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 36 | marked_unread::{MarkedUnreadEventContent, UnstableMarkedUnreadEventContent}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 37 | media_preview_config::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 38 | InviteAvatars as RumaInviteAvatars, MediaPreviewConfigEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 39 | MediaPreviews as RumaMediaPreviews, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 40 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 41 | poll::start::PollKind as RumaPollKind, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 42 | push_rules::PushRulesEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 43 | room::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 44 | ImageInfo as RumaImageInfo, MediaSource as RumaMediaSource, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 45 | ThumbnailInfo as RumaThumbnailInfo, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 46 | message::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 47 | AudioInfo as RumaAudioInfo, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 48 | AudioMessageEventContent as RumaAudioMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 49 | EmoteMessageEventContent as RumaEmoteMessageEventContent, FileInfo as RumaFileInfo, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 50 | FileMessageEventContent as RumaFileMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 51 | FormattedBody as RumaFormattedBody, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 52 | ImageMessageEventContent as RumaImageMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 53 | LocationMessageEventContent as RumaLocationMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 54 | MessageType as RumaMessageType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 55 | NoticeMessageEventContent as RumaNoticeMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 56 | RoomMessageEventContentWithoutRelation, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 57 | TextMessageEventContent as RumaTextMessageEventContent, UnstableAmplitude, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 58 | UnstableAudioDetailsContentBlock as RumaUnstableAudioDetailsContentBlock, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 59 | UnstableVoiceContentBlock as RumaUnstableVoiceContentBlock, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 60 | VideoInfo as RumaVideoInfo, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 61 | VideoMessageEventContent as RumaVideoMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 62 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 63 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 64 | rtc::notification::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 65 | CallIntent as RumaCallIntent, NotificationType as RumaNotificationType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 66 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 67 | secret_storage::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 68 | default_key::SecretStorageDefaultKeyEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 69 | key::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 70 | PassPhrase as RumaPassPhrase, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 71 | SecretStorageEncryptionAlgorithm as RumaSecretStorageEncryptionAlgorithm, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 72 | SecretStorageKeyEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 73 | SecretStorageV1AesHmacSha2Properties as RumaSecretStorageV1AesHmacSha2Properties, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 74 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 75 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 76 | tag::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 77 | TagEventContent, TagInfo as RumaTagInfo, TagName as RumaTagName, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 78 | UserTagName as RumaUserTagName, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 79 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 80 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 81 | matrix_uri::MatrixId as RumaMatrixId, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 82 | push::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 83 | ConditionalPushRule as RumaConditionalPushRule, PatternedPushRule as RumaPatternedPushRule, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 84 | Ruleset as RumaRuleset, SimplePushRule as RumaSimplePushRule, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 85 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 86 | serde::JsonObject, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 87 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 88 | use tracing::info; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 89 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 90 | use crate::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 91 | error::{ClientError, MediaInfoError}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 92 | helpers::unwrap_or_clone_arc, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 93 | notification_settings::{Action, PushCondition}, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 94 | timeline::MessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 95 | utils::u64_to_uint, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 96 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 97 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 98 | #[derive(uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 99 | pub enum AuthData { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 100 | /// Password-based authentication (`m.login.password`). |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 101 | Password { password_details: AuthDataPasswordDetails }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 102 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 103 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 104 | #[derive(uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 105 | pub struct AuthDataPasswordDetails { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 106 | /// One of the user's identifiers. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 107 | identifier: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 108 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 109 | /// The plaintext password. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 110 | password: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 111 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 112 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 113 | impl From<AuthData> for ruma::api::client::uiaa::AuthData { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 114 | fn from(value: AuthData) -> ruma::api::client::uiaa::AuthData { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 115 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 116 | AuthData::Password { password_details } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 117 | let user_id = ruma::UserId::parse(password_details.identifier).unwrap(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 118 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 119 | ruma::api::client::uiaa::AuthData::Password(ruma::api::client::uiaa::Password::new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 120 | user_id.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 121 | password_details.password, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 122 | )) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 123 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 124 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 125 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 126 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 127 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 128 | /// Parse a matrix entity from a given URI, be it either |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 129 | /// a `matrix.to` link or a `matrix:` URI |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 130 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 131 | pub fn parse_matrix_entity_from(uri: String) -> Option<MatrixEntity> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 132 | if let Ok(matrix_uri) = RumaMatrixUri::parse(&uri) { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 133 | return Some(MatrixEntity { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 134 | id: matrix_uri.id().into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 135 | via: matrix_uri.via().iter().map(|via| via.to_string()).collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 136 | }); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 137 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 138 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 139 | if let Ok(matrix_to_uri) = MatrixToUri::parse(&uri) { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 140 | return Some(MatrixEntity { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 141 | id: matrix_to_uri.id().into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 142 | via: matrix_to_uri.via().iter().map(|via| via.to_string()).collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 143 | }); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 144 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 145 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 146 | None |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 147 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 148 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 149 | /// A Matrix entity that can be a room, room alias, user, or event, and a list |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 150 | /// of via servers. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 151 | #[derive(uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 152 | pub struct MatrixEntity { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 153 | id: MatrixId, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 154 | via: Vec<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 155 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 156 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 157 | /// A Matrix ID that can be a room, room alias, user, or event. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 158 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 159 | pub enum MatrixId { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 160 | Room { id: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 161 | RoomAlias { alias: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 162 | User { id: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 163 | EventOnRoomId { room_id: String, event_id: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 164 | EventOnRoomAlias { alias: String, event_id: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 165 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 166 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 167 | impl From<&RumaMatrixId> for MatrixId { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 168 | fn from(value: &RumaMatrixId) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 169 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 170 | RumaMatrixId::User(id) => MatrixId::User { id: id.to_string() }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 171 | RumaMatrixId::Room(id) => MatrixId::Room { id: id.to_string() }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 172 | RumaMatrixId::RoomAlias(id) => MatrixId::RoomAlias { alias: id.to_string() }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 173 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 174 | RumaMatrixId::Event(room_id_or_alias, event_id) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 175 | if room_id_or_alias.is_room_id() { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 176 | MatrixId::EventOnRoomId { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 177 | room_id: room_id_or_alias.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 178 | event_id: event_id.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 179 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 180 | } else if room_id_or_alias.is_room_alias_id() { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 181 | MatrixId::EventOnRoomAlias { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 182 | alias: room_id_or_alias.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 183 | event_id: event_id.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 184 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 185 | } else { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 186 | panic!("Unexpected MatrixId type: {room_id_or_alias:?}") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 187 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 188 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 189 | _ => panic!("Unexpected MatrixId type: {value:?}"), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 190 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 191 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 192 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 193 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 194 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 195 | pub fn message_event_content_new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 196 | msgtype: MessageType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 197 | ) -> Result<Arc<RoomMessageEventContentWithoutRelation>, ClientError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 198 | Ok(Arc::new(RoomMessageEventContentWithoutRelation::new(msgtype.try_into()?))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 199 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 200 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 201 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 202 | pub fn message_event_content_from_markdown( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 203 | md: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 204 | ) -> Arc<RoomMessageEventContentWithoutRelation> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 205 | Arc::new(RoomMessageEventContentWithoutRelation::new(RumaMessageType::text_markdown(md))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 206 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 207 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 208 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 209 | pub fn message_event_content_from_markdown_as_emote( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 210 | md: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 211 | ) -> Arc<RoomMessageEventContentWithoutRelation> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 212 | Arc::new(RoomMessageEventContentWithoutRelation::new(RumaMessageType::emote_markdown(md))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 213 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 214 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 215 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 216 | pub fn message_event_content_from_html( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 217 | body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 218 | html_body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 219 | ) -> Arc<RoomMessageEventContentWithoutRelation> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 220 | Arc::new(RoomMessageEventContentWithoutRelation::new(RumaMessageType::text_html( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 221 | body, html_body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 222 | ))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 223 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 224 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 225 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 226 | pub fn message_event_content_from_html_as_emote( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 227 | body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 228 | html_body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 229 | ) -> Arc<RoomMessageEventContentWithoutRelation> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 230 | Arc::new(RoomMessageEventContentWithoutRelation::new(RumaMessageType::emote_html( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 231 | body, html_body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 232 | ))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 233 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 234 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 235 | #[derive(Clone, uniffi::Object)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 236 | pub struct MediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 237 | pub(crate) media_source: RumaMediaSource, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 238 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 239 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 240 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 241 | impl MediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 242 | #[uniffi::constructor] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 243 | pub fn from_url(url: String) -> Result<Arc<MediaSource>, ClientError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 244 | let media_source = RumaMediaSource::Plain(url.into()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 245 | media_source.verify()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 246 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 247 | Ok(Arc::new(MediaSource { media_source })) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 248 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 249 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 250 | pub fn url(&self) -> String { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 251 | self.media_source.url() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 252 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 253 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 254 | // Used on Element X Android |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 255 | #[uniffi::constructor] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 256 | pub fn from_json(json: String) -> Result<Arc<Self>, ClientError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 257 | let media_source: RumaMediaSource = serde_json::from_str(&json)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 258 | media_source.verify()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 259 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 260 | Ok(Arc::new(MediaSource { media_source })) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 261 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 262 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 263 | // Used on Element X Android |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 264 | pub fn to_json(&self) -> String { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 265 | serde_json::to_string(&self.media_source) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 266 | .expect("Media source should always be serializable ") |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 267 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 268 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 269 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 270 | impl TryFrom<RumaMediaSource> for MediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 271 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 272 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 273 | fn try_from(value: RumaMediaSource) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 274 | value.verify()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 275 | Ok(Self { media_source: value }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 276 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 277 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 278 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 279 | impl TryFrom<&RumaMediaSource> for MediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 280 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 281 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 282 | fn try_from(value: &RumaMediaSource) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 283 | value.verify()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 284 | Ok(Self { media_source: value.clone() }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 285 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 286 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 287 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 288 | impl From<MediaSource> for RumaMediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 289 | fn from(value: MediaSource) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 290 | value.media_source |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 291 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 292 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 293 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 294 | #[extension_trait] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 295 | pub(crate) impl MediaSourceExt for RumaMediaSource { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 296 | fn verify(&self) -> Result<(), ClientError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 297 | match self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 298 | RumaMediaSource::Plain(url) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 299 | url.validate().map_err(ClientError::from_err)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 300 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 301 | RumaMediaSource::Encrypted(file) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 302 | file.url.validate().map_err(ClientError::from_err)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 303 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 304 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 305 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 306 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 307 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 308 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 309 | fn url(&self) -> String { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 310 | match self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 311 | RumaMediaSource::Plain(url) => url.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 312 | RumaMediaSource::Encrypted(file) => file.url.to_string(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 313 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 314 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 315 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 316 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 317 | #[extension_trait] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 318 | pub impl RoomMessageEventContentWithoutRelationExt for RoomMessageEventContentWithoutRelation { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 319 | fn with_mentions(self: Arc<Self>, mentions: Mentions) -> Arc<Self> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 320 | let mut content = unwrap_or_clone_arc(self); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 321 | content.mentions = Some(mentions.into()); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 322 | Arc::new(content) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 323 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 324 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 325 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 326 | #[derive(Clone)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 327 | pub struct Mentions { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 328 | pub user_ids: Vec<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 329 | pub room: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 330 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 331 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 332 | impl From<Mentions> for ruma::events::Mentions { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 333 | fn from(value: Mentions) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 334 | let mut user_ids = BTreeSet::<OwnedUserId>::new(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 335 | for user_id in value.user_ids { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 336 | if let Ok(user_id) = UserId::parse(user_id) { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 337 | user_ids.insert(user_id); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 338 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 339 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 340 | let mut result = Self::default(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 341 | result.user_ids = user_ids; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 342 | result.room = value.room; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 343 | result |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 344 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 345 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 346 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 347 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 348 | pub enum MessageType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 349 | Emote { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 350 | content: EmoteMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 351 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 352 | Image { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 353 | content: ImageMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 354 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 355 | Audio { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 356 | content: AudioMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 357 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 358 | Video { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 359 | content: VideoMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 360 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 361 | File { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 362 | content: FileMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 363 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 364 | #[cfg(feature = "unstable-msc4274")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 365 | Gallery { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 366 | content: GalleryMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 367 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 368 | Notice { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 369 | content: NoticeMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 370 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 371 | Text { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 372 | content: TextMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 373 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 374 | Location { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 375 | content: LocationContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 376 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 377 | Other { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 378 | msgtype: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 379 | body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 380 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 381 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 382 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 383 | /// From MSC2530: https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/2530-body-as-caption.md |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 384 | /// If the filename field is present in a media message, clients should treat |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 385 | /// body as a caption instead of a file name. Otherwise, the body is the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 386 | /// file name. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 387 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 388 | /// So: |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 389 | /// - if a media has a filename and a caption, the body is the caption, filename |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 390 | /// is its own field. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 391 | /// - if a media only has a filename, then body is the filename. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 392 | fn get_body_and_filename(filename: String, caption: Option<String>) -> (String, Option<String>) { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 393 | if let Some(caption) = caption { (caption, Some(filename)) } else { (filename, None) } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 394 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 395 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 396 | impl TryFrom<MessageType> for RumaMessageType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 397 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 398 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 399 | fn try_from(value: MessageType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 400 | Ok(match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 401 | MessageType::Emote { content } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 402 | Self::Emote(assign!(RumaEmoteMessageEventContent::plain(content.body), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 403 | formatted: content.formatted.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 404 | })) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 405 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 406 | MessageType::Image { content } => Self::Image(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 407 | MessageType::Audio { content } => Self::Audio(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 408 | MessageType::Video { content } => Self::Video(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 409 | MessageType::File { content } => Self::File(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 410 | #[cfg(feature = "unstable-msc4274")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 411 | MessageType::Gallery { content } => Self::Gallery(content.try_into()?), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 412 | MessageType::Notice { content } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 413 | Self::Notice(assign!(RumaNoticeMessageEventContent::plain(content.body), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 414 | formatted: content.formatted.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 415 | })) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 416 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 417 | MessageType::Text { content } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 418 | Self::Text(assign!(RumaTextMessageEventContent::plain(content.body), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 419 | formatted: content.formatted.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 420 | })) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 421 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 422 | MessageType::Location { content } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 423 | Self::Location(RumaLocationMessageEventContent::new(content.body, content.geo_uri)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 424 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 425 | MessageType::Other { msgtype, body } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 426 | Self::new(&msgtype, body, JsonObject::default())? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 427 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 428 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 429 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 430 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 431 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 432 | impl TryFrom<RumaMessageType> for MessageType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 433 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 434 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 435 | fn try_from(value: RumaMessageType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 436 | Ok(match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 437 | RumaMessageType::Emote(c) => MessageType::Emote { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 438 | content: EmoteMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 439 | body: c.body.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 440 | formatted: c.formatted.as_ref().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 441 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 442 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 443 | RumaMessageType::Image(c) => MessageType::Image { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 444 | RumaMessageType::Audio(c) => MessageType::Audio { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 445 | RumaMessageType::Video(c) => MessageType::Video { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 446 | RumaMessageType::File(c) => MessageType::File { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 447 | #[cfg(feature = "unstable-msc4274")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 448 | RumaMessageType::Gallery(c) => MessageType::Gallery { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 449 | RumaMessageType::Notice(c) => MessageType::Notice { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 450 | content: NoticeMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 451 | body: c.body.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 452 | formatted: c.formatted.as_ref().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 453 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 454 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 455 | RumaMessageType::Text(c) => MessageType::Text { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 456 | content: TextMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 457 | body: c.body.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 458 | formatted: c.formatted.as_ref().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 459 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 460 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 461 | RumaMessageType::Location(c) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 462 | let (description, zoom_level) = |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 463 | c.location.map(|loc| (loc.description, loc.zoom_level)).unwrap_or((None, None)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 464 | MessageType::Location { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 465 | content: LocationContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 466 | body: c.body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 467 | geo_uri: c.geo_uri, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 468 | description, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 469 | zoom_level: zoom_level.and_then(|z| z.get().try_into().ok()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 470 | asset: c.asset.map(|a| a.type_).into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 471 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 472 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 473 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 474 | _ => MessageType::Other { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 475 | msgtype: value.msgtype().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 476 | body: value.body().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 477 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 478 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 479 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 480 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 481 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 482 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 483 | pub enum RtcNotificationType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 484 | Ring, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 485 | Notification, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 486 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 487 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 488 | impl From<RumaNotificationType> for RtcNotificationType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 489 | fn from(val: RumaNotificationType) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 490 | match val { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 491 | RumaNotificationType::Ring => Self::Ring, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 492 | _ => Self::Notification, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 493 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 494 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 495 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 496 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 497 | impl From<RtcNotificationType> for RumaNotificationType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 498 | fn from(value: RtcNotificationType) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 499 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 500 | RtcNotificationType::Ring => RumaNotificationType::Ring, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 501 | RtcNotificationType::Notification => RumaNotificationType::Notification, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 502 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 503 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 504 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 505 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 506 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 507 | pub enum RtcCallIntent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 508 | Video, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 509 | Audio, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 510 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 511 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 512 | impl From<RumaCallIntent> for RtcCallIntent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 513 | fn from(val: RumaCallIntent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 514 | match val { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 515 | RumaCallIntent::Audio => Self::Audio, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 516 | // No support for custom intents, so we can just use video as default |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 517 | _ => Self::Video, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 518 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 519 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 520 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 521 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 522 | impl From<RtcCallIntent> for RumaCallIntent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 523 | fn from(value: RtcCallIntent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 524 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 525 | RtcCallIntent::Video => RumaCallIntent::Video, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 526 | RtcCallIntent::Audio => RumaCallIntent::Audio, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 527 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 528 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 529 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 530 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 531 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 532 | pub struct EmoteMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 533 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 534 | pub formatted: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 535 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 536 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 537 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 538 | pub struct ImageMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 539 | /// The computed filename, for use in a client. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 540 | pub filename: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 541 | pub caption: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 542 | pub formatted_caption: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 543 | pub source: Arc<MediaSource>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 544 | pub info: Option<ImageInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 545 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 546 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 547 | impl From<ImageMessageContent> for RumaImageMessageEventContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 548 | fn from(value: ImageMessageContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 549 | let (body, filename) = get_body_and_filename(value.filename, value.caption); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 550 | let mut event_content = Self::new(body, (*value.source).clone().into()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 551 | .info(value.info.map(Into::into).map(Box::new)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 552 | event_content.formatted = value.formatted_caption.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 553 | event_content.filename = filename; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 554 | event_content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 555 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 556 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 557 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 558 | impl TryFrom<RumaImageMessageEventContent> for ImageMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 559 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 560 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 561 | fn try_from(value: RumaImageMessageEventContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 562 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 563 | filename: value.filename().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 564 | caption: value.caption().map(str::to_owned), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 565 | formatted_caption: value.formatted_caption().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 566 | source: Arc::new(value.source.try_into()?), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 567 | info: value.info.as_deref().map(TryInto::try_into).transpose()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 568 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 569 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 570 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 571 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 572 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 573 | pub struct AudioMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 574 | /// The computed filename, for use in a client. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 575 | pub filename: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 576 | pub caption: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 577 | pub formatted_caption: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 578 | pub source: Arc<MediaSource>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 579 | pub info: Option<AudioInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 580 | pub audio: Option<UnstableAudioDetailsContent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 581 | pub voice: Option<UnstableVoiceContent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 582 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 583 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 584 | impl From<AudioMessageContent> for RumaAudioMessageEventContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 585 | fn from(value: AudioMessageContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 586 | let (body, filename) = get_body_and_filename(value.filename, value.caption); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 587 | let mut event_content = Self::new(body, (*value.source).clone().into()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 588 | .info(value.info.map(Into::into).map(Box::new)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 589 | event_content.formatted = value.formatted_caption.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 590 | event_content.filename = filename; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 591 | event_content.audio = value.audio.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 592 | event_content.voice = value.voice.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 593 | event_content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 594 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 595 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 596 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 597 | impl TryFrom<RumaAudioMessageEventContent> for AudioMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 598 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 599 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 600 | fn try_from(value: RumaAudioMessageEventContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 601 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 602 | filename: value.filename().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 603 | caption: value.caption().map(str::to_owned), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 604 | formatted_caption: value.formatted_caption().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 605 | source: Arc::new(value.source.try_into()?), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 606 | info: value.info.as_deref().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 607 | audio: value.audio.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 608 | voice: value.voice.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 609 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 610 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 611 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 612 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 613 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 614 | pub struct VideoMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 615 | /// The computed filename, for use in a client. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 616 | pub filename: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 617 | pub caption: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 618 | pub formatted_caption: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 619 | pub source: Arc<MediaSource>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 620 | pub info: Option<VideoInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 621 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 622 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 623 | impl From<VideoMessageContent> for RumaVideoMessageEventContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 624 | fn from(value: VideoMessageContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 625 | let (body, filename) = get_body_and_filename(value.filename, value.caption); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 626 | let mut event_content = Self::new(body, (*value.source).clone().into()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 627 | .info(value.info.map(Into::into).map(Box::new)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 628 | event_content.formatted = value.formatted_caption.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 629 | event_content.filename = filename; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 630 | event_content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 631 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 632 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 633 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 634 | impl TryFrom<RumaVideoMessageEventContent> for VideoMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 635 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 636 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 637 | fn try_from(value: RumaVideoMessageEventContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 638 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 639 | filename: value.filename().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 640 | caption: value.caption().map(str::to_owned), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 641 | formatted_caption: value.formatted_caption().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 642 | source: Arc::new(value.source.try_into()?), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 643 | info: value.info.as_deref().map(TryInto::try_into).transpose()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 644 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 645 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 646 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 647 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 648 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 649 | pub struct FileMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 650 | /// The computed filename, for use in a client. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 651 | pub filename: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 652 | pub caption: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 653 | pub formatted_caption: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 654 | pub source: Arc<MediaSource>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 655 | pub info: Option<FileInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 656 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 657 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 658 | impl From<FileMessageContent> for RumaFileMessageEventContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 659 | fn from(value: FileMessageContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 660 | let (body, filename) = get_body_and_filename(value.filename, value.caption); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 661 | let mut event_content = Self::new(body, (*value.source).clone().into()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 662 | .info(value.info.map(Into::into).map(Box::new)); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 663 | event_content.formatted = value.formatted_caption.map(Into::into); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 664 | event_content.filename = filename; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 665 | event_content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 666 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 667 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 668 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 669 | impl TryFrom<RumaFileMessageEventContent> for FileMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 670 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 671 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 672 | fn try_from(value: RumaFileMessageEventContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 673 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 674 | filename: value.filename().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 675 | caption: value.caption().map(str::to_owned), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 676 | formatted_caption: value.formatted_caption().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 677 | source: Arc::new(value.source.try_into()?), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 678 | info: value.info.as_deref().map(TryInto::try_into).transpose()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 679 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 680 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 681 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 682 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 683 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 684 | pub struct ImageInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 685 | pub height: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 686 | pub width: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 687 | pub mimetype: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 688 | pub size: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 689 | pub thumbnail_info: Option<ThumbnailInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 690 | pub thumbnail_source: Option<Arc<MediaSource>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 691 | pub blurhash: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 692 | pub is_animated: Option<bool>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 693 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 694 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 695 | impl From<ImageInfo> for RumaImageInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 696 | fn from(value: ImageInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 697 | assign!(RumaImageInfo::new(), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 698 | height: value.height.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 699 | width: value.width.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 700 | mimetype: value.mimetype, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 701 | size: value.size.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 702 | thumbnail_info: value.thumbnail_info.map(Into::into).map(Box::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 703 | thumbnail_source: value.thumbnail_source.map(|source| (*source).clone().into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 704 | blurhash: value.blurhash, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 705 | is_animated: value.is_animated, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 706 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 707 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 708 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 709 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 710 | impl TryFrom<&ImageInfo> for BaseImageInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 711 | type Error = MediaInfoError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 712 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 713 | fn try_from(value: &ImageInfo) -> Result<Self, MediaInfoError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 714 | let height = UInt::try_from(value.height.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 715 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 716 | let width = UInt::try_from(value.width.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 717 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 718 | let size = UInt::try_from(value.size.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 719 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 720 | let blurhash = value.blurhash.clone().ok_or(MediaInfoError::MissingField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 721 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 722 | Ok(BaseImageInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 723 | height: Some(height), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 724 | width: Some(width), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 725 | size: Some(size), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 726 | blurhash: Some(blurhash), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 727 | is_animated: value.is_animated, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 728 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 729 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 730 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 731 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 732 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 733 | pub struct AudioInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 734 | pub duration: Option<Duration>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 735 | pub size: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 736 | pub mimetype: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 737 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 738 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 739 | impl From<AudioInfo> for RumaAudioInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 740 | fn from(value: AudioInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 741 | assign!(RumaAudioInfo::new(), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 742 | duration: value.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 743 | size: value.size.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 744 | mimetype: value.mimetype, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 745 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 746 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 747 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 748 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 749 | impl TryFrom<&AudioInfo> for BaseAudioInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 750 | type Error = MediaInfoError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 751 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 752 | fn try_from(value: &AudioInfo) -> Result<Self, MediaInfoError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 753 | let duration = value.duration.ok_or(MediaInfoError::MissingField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 754 | let size = UInt::try_from(value.size.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 755 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 756 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 757 | Ok(BaseAudioInfo { duration: Some(duration), size: Some(size), waveform: None }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 758 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 759 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 760 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 761 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 762 | pub struct UnstableAudioDetailsContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 763 | pub duration: Duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 764 | pub waveform: Vec<u16>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 765 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 766 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 767 | impl From<RumaUnstableAudioDetailsContentBlock> for UnstableAudioDetailsContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 768 | fn from(details: RumaUnstableAudioDetailsContentBlock) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 769 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 770 | duration: details.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 771 | waveform: details |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 772 | .waveform |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 773 | .iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 774 | .map(|x| u16::try_from(x.get()).unwrap_or(0)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 775 | .collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 776 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 777 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 778 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 779 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 780 | impl From<UnstableAudioDetailsContent> for RumaUnstableAudioDetailsContentBlock { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 781 | fn from(details: UnstableAudioDetailsContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 782 | Self::new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 783 | details.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 784 | details.waveform.iter().map(|x| UnstableAmplitude::new(x.to_owned())).collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 785 | ) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 786 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 787 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 788 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 789 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 790 | pub struct UnstableVoiceContent {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 791 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 792 | impl From<RumaUnstableVoiceContentBlock> for UnstableVoiceContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 793 | fn from(_details: RumaUnstableVoiceContentBlock) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 794 | Self {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 795 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 796 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 797 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 798 | impl From<UnstableVoiceContent> for RumaUnstableVoiceContentBlock { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 799 | fn from(_details: UnstableVoiceContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 800 | Self::new() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 801 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 802 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 803 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 804 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 805 | pub struct VideoInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 806 | pub duration: Option<Duration>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 807 | pub height: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 808 | pub width: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 809 | pub mimetype: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 810 | pub size: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 811 | pub thumbnail_info: Option<ThumbnailInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 812 | pub thumbnail_source: Option<Arc<MediaSource>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 813 | pub blurhash: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 814 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 815 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 816 | impl From<VideoInfo> for RumaVideoInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 817 | fn from(value: VideoInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 818 | assign!(RumaVideoInfo::new(), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 819 | duration: value.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 820 | height: value.height.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 821 | width: value.width.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 822 | mimetype: value.mimetype, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 823 | size: value.size.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 824 | thumbnail_info: value.thumbnail_info.map(Into::into).map(Box::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 825 | thumbnail_source: value.thumbnail_source.map(|source| (*source).clone().into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 826 | blurhash: value.blurhash, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 827 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 828 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 829 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 830 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 831 | impl TryFrom<&VideoInfo> for BaseVideoInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 832 | type Error = MediaInfoError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 833 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 834 | fn try_from(value: &VideoInfo) -> Result<Self, MediaInfoError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 835 | let duration = value.duration.ok_or(MediaInfoError::MissingField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 836 | let height = UInt::try_from(value.height.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 837 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 838 | let width = UInt::try_from(value.width.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 839 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 840 | let size = UInt::try_from(value.size.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 841 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 842 | let blurhash = value.blurhash.clone().ok_or(MediaInfoError::MissingField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 843 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 844 | Ok(BaseVideoInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 845 | duration: Some(duration), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 846 | height: Some(height), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 847 | width: Some(width), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 848 | size: Some(size), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 849 | blurhash: Some(blurhash), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 850 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 851 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 852 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 853 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 854 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 855 | pub struct FileInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 856 | pub mimetype: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 857 | pub size: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 858 | pub thumbnail_info: Option<ThumbnailInfo>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 859 | pub thumbnail_source: Option<Arc<MediaSource>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 860 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 861 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 862 | impl From<FileInfo> for RumaFileInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 863 | fn from(value: FileInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 864 | assign!(RumaFileInfo::new(), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 865 | mimetype: value.mimetype, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 866 | size: value.size.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 867 | thumbnail_info: value.thumbnail_info.map(Into::into).map(Box::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 868 | thumbnail_source: value.thumbnail_source.map(|source| (*source).clone().into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 869 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 870 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 871 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 872 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 873 | impl TryFrom<&FileInfo> for BaseFileInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 874 | type Error = MediaInfoError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 875 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 876 | fn try_from(value: &FileInfo) -> Result<Self, MediaInfoError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 877 | let size = UInt::try_from(value.size.ok_or(MediaInfoError::MissingField)?) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 878 | .map_err(|_| MediaInfoError::InvalidField)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 879 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 880 | Ok(BaseFileInfo { size: Some(size) }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 881 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 882 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 883 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 884 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 885 | pub struct ThumbnailInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 886 | pub height: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 887 | pub width: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 888 | pub mimetype: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 889 | pub size: Option<u64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 890 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 891 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 892 | impl From<ThumbnailInfo> for RumaThumbnailInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 893 | fn from(value: ThumbnailInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 894 | assign!(RumaThumbnailInfo::new(), { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 895 | height: value.height.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 896 | width: value.width.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 897 | mimetype: value.mimetype, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 898 | size: value.size.map(u64_to_uint), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 899 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 900 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 901 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 902 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 903 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 904 | pub struct NoticeMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 905 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 906 | pub formatted: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 907 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 908 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 909 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 910 | pub struct TextMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 911 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 912 | pub formatted: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 913 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 914 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 915 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 916 | pub struct LocationContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 917 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 918 | pub geo_uri: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 919 | pub description: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 920 | pub zoom_level: Option<u8>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 921 | pub asset: AssetType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 922 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 923 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 924 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 925 | pub enum AssetType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 926 | Sender, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 927 | Pin, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 928 | Unknown, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 929 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 930 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 931 | impl From<AssetType> for RumaAssetType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 932 | fn from(value: AssetType) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 933 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 934 | AssetType::Sender => Self::Self_, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 935 | AssetType::Pin => Self::Pin, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 936 | _ => panic!("Invalid asset type"), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 937 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 938 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 939 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 940 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 941 | impl From<RumaAssetType> for AssetType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 942 | fn from(value: RumaAssetType) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 943 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 944 | RumaAssetType::Self_ => Self::Sender, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 945 | RumaAssetType::Pin => Self::Pin, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 946 | _ => Self::Unknown, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 947 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 948 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 949 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 950 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 951 | impl From<Option<RumaAssetType>> for AssetType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 952 | fn from(value: Option<RumaAssetType>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 953 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 954 | None => Self::Sender, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 955 | Some(asset_type) => asset_type.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 956 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 957 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 958 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 959 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 960 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 961 | pub struct FormattedBody { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 962 | pub format: MessageFormat, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 963 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 964 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 965 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 966 | impl From<FormattedBody> for RumaFormattedBody { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 967 | fn from(f: FormattedBody) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 968 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 969 | format: match f.format { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 970 | MessageFormat::Html => matrix_sdk::ruma::events::room::message::MessageFormat::Html, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 971 | MessageFormat::Unknown { format } => format.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 972 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 973 | body: f.body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 974 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 975 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 976 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 977 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 978 | impl From<&RumaFormattedBody> for FormattedBody { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 979 | fn from(f: &RumaFormattedBody) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 980 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 981 | format: match &f.format { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 982 | matrix_sdk::ruma::events::room::message::MessageFormat::Html => MessageFormat::Html, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 983 | _ => MessageFormat::Unknown { format: f.format.to_string() }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 984 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 985 | body: f.body.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 986 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 987 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 988 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 989 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 990 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 991 | pub enum MessageFormat { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 992 | Html, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 993 | Unknown { format: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 994 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 995 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 996 | impl TryFrom<&matrix_sdk::ruma::events::room::ImageInfo> for ImageInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 997 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 998 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 999 | fn try_from(info: &matrix_sdk::ruma::events::room::ImageInfo) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1000 | let thumbnail_info = info.thumbnail_info.as_ref().map(|info| ThumbnailInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1001 | height: info.height.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1002 | width: info.width.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1003 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1004 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1005 | }); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1006 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1007 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1008 | height: info.height.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1009 | width: info.width.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1010 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1011 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1012 | thumbnail_info, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1013 | thumbnail_source: info |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1014 | .thumbnail_source |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1015 | .as_ref() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1016 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1017 | .transpose()? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1018 | .map(Arc::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1019 | blurhash: info.blurhash.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1020 | is_animated: info.is_animated, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1021 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1022 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1023 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1024 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1025 | impl From<&RumaAudioInfo> for AudioInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1026 | fn from(info: &RumaAudioInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1027 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1028 | duration: info.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1029 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1030 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1031 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1032 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1033 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1034 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1035 | impl TryFrom<&RumaVideoInfo> for VideoInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1036 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1037 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1038 | fn try_from(info: &RumaVideoInfo) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1039 | let thumbnail_info = info.thumbnail_info.as_ref().map(|info| ThumbnailInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1040 | height: info.height.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1041 | width: info.width.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1042 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1043 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1044 | }); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1045 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1046 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1047 | duration: info.duration, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1048 | height: info.height.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1049 | width: info.width.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1050 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1051 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1052 | thumbnail_info, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1053 | thumbnail_source: info |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1054 | .thumbnail_source |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1055 | .as_ref() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1056 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1057 | .transpose()? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1058 | .map(Arc::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1059 | blurhash: info.blurhash.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1060 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1061 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1062 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1063 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1064 | impl TryFrom<&RumaFileInfo> for FileInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1065 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1066 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1067 | fn try_from(info: &RumaFileInfo) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1068 | let thumbnail_info = info.thumbnail_info.as_ref().map(|info| ThumbnailInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1069 | height: info.height.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1070 | width: info.width.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1071 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1072 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1073 | }); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1074 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1075 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1076 | mimetype: info.mimetype.clone(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1077 | size: info.size.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1078 | thumbnail_info, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1079 | thumbnail_source: info |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1080 | .thumbnail_source |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1081 | .as_ref() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1082 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1083 | .transpose()? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1084 | .map(Arc::new), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1085 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1086 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1087 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1088 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1089 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1090 | pub enum PollKind { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1091 | Disclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1092 | Undisclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1093 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1094 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1095 | impl From<PollKind> for RumaPollKind { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1096 | fn from(value: PollKind) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1097 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1098 | PollKind::Disclosed => Self::Disclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1099 | PollKind::Undisclosed => Self::Undisclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1100 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1101 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1102 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1103 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1104 | impl From<RumaPollKind> for PollKind { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1105 | fn from(value: RumaPollKind) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1106 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1107 | RumaPollKind::Disclosed => Self::Disclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1108 | RumaPollKind::Undisclosed => Self::Undisclosed, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1109 | _ => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1110 | info!("Unknown poll kind, defaulting to undisclosed"); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1111 | Self::Undisclosed |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1112 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1113 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1114 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1115 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1116 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1117 | /// Creates a [`RoomMessageEventContentWithoutRelation`] given a |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1118 | /// [`MessageContent`] value. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1119 | #[matrix_sdk_ffi_macros::export] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1120 | pub fn content_without_relation_from_message( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1121 | message: MessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1122 | ) -> Result<Arc<RoomMessageEventContentWithoutRelation>, ClientError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1123 | let msg_type = message.msg_type.try_into()?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1124 | Ok(Arc::new(RoomMessageEventContentWithoutRelation::new(msg_type))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1125 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1126 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1127 | /// Types of global account data events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1128 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1129 | pub enum AccountDataEventType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1130 | /// m.direct |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1131 | Direct, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1132 | /// m.identity_server |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1133 | IdentityServer, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1134 | /// m.ignored_user_list |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1135 | IgnoredUserList, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1136 | /// m.push_rules |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1137 | PushRules, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1138 | /// m.secret_storage.default_key |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1139 | SecretStorageDefaultKey, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1140 | /// m.secret_storage.key.* |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1141 | SecretStorageKey { key_id: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1142 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1143 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1144 | impl TryFrom<RumaGlobalAccountDataEventType> for AccountDataEventType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1145 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1146 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1147 | fn try_from(value: RumaGlobalAccountDataEventType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1148 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1149 | RumaGlobalAccountDataEventType::Direct => Ok(Self::Direct), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1150 | RumaGlobalAccountDataEventType::IdentityServer => Ok(Self::IdentityServer), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1151 | RumaGlobalAccountDataEventType::IgnoredUserList => Ok(Self::IgnoredUserList), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1152 | RumaGlobalAccountDataEventType::PushRules => Ok(Self::PushRules), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1153 | RumaGlobalAccountDataEventType::SecretStorageDefaultKey => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1154 | Ok(Self::SecretStorageDefaultKey) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1155 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1156 | RumaGlobalAccountDataEventType::SecretStorageKey(key_id) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1157 | Ok(Self::SecretStorageKey { key_id }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1158 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1159 | _ => Err("Unsupported account data event type".to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1160 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1161 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1162 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1163 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1164 | /// Global account data events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1165 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1166 | pub enum AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1167 | /// m.direct |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1168 | Direct { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1169 | /// The mapping of user ID to a list of room IDs of the ‘direct’ rooms |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1170 | /// for that user ID. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1171 | map: HashMap<String, Vec<String>>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1172 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1173 | /// m.identity_server |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1174 | IdentityServer { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1175 | /// The base URL for the identity server for client-server connections. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1176 | base_url: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1177 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1178 | /// m.ignored_user_list |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1179 | IgnoredUserList { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1180 | /// The map of users to ignore. This is a mapping of user ID to empty |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1181 | /// object. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1182 | ignored_users: HashMap<String, IgnoredUser>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1183 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1184 | /// m.push_rules |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1185 | PushRules { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1186 | /// The global ruleset. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1187 | global: Ruleset, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1188 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1189 | /// m.secret_storage.default_key |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1190 | SecretStorageDefaultKey { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1191 | /// The ID of the default key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1192 | key_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1193 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1194 | /// m.secret_storage.key.* |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1195 | SecretStorageKey { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1196 | /// The ID of the key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1197 | key_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1198 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1199 | /// The name of the key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1200 | name: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1201 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1202 | /// The encryption algorithm used for this key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1203 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1204 | /// Currently, only `m.secret_storage.v1.aes-hmac-sha2` is supported. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1205 | algorithm: SecretStorageEncryptionAlgorithm, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1206 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1207 | /// The passphrase from which to generate the key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1208 | passphrase: Option<PassPhrase>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1209 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1210 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1211 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1212 | /// The policy that decides if media previews should be shown in the timeline. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1213 | #[derive(Clone, uniffi::Enum, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1214 | pub enum MediaPreviews { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1215 | /// Always show media previews in the timeline. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1216 | #[default] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1217 | On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1218 | /// Show media previews in the timeline only if the room is private. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1219 | Private, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1220 | /// Never show media previews in the timeline. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1221 | Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1222 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1223 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1224 | impl From<RumaMediaPreviews> for MediaPreviews { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1225 | fn from(value: RumaMediaPreviews) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1226 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1227 | RumaMediaPreviews::On => Self::On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1228 | RumaMediaPreviews::Private => Self::Private, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1229 | RumaMediaPreviews::Off => Self::Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1230 | _ => Default::default(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1231 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1232 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1233 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1234 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1235 | impl From<MediaPreviews> for RumaMediaPreviews { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1236 | fn from(value: MediaPreviews) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1237 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1238 | MediaPreviews::On => Self::On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1239 | MediaPreviews::Private => Self::Private, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1240 | MediaPreviews::Off => Self::Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1241 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1242 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1243 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1244 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1245 | /// The policy that decides if avatars should be shown in invite requests. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1246 | #[derive(Clone, uniffi::Enum, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1247 | pub enum InviteAvatars { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1248 | /// Always show avatars in invite requests. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1249 | #[default] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1250 | On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1251 | /// Never show avatars in invite requests. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1252 | Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1253 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1254 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1255 | impl From<RumaInviteAvatars> for InviteAvatars { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1256 | fn from(value: RumaInviteAvatars) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1257 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1258 | RumaInviteAvatars::On => Self::On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1259 | RumaInviteAvatars::Off => Self::Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1260 | _ => Default::default(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1261 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1262 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1263 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1264 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1265 | impl From<InviteAvatars> for RumaInviteAvatars { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1266 | fn from(value: InviteAvatars) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1267 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1268 | InviteAvatars::On => Self::On, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1269 | InviteAvatars::Off => Self::Off, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1270 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1271 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1272 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1273 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1274 | /// Details about an ignored user. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1275 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1276 | /// This is currently empty. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1277 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1278 | pub struct IgnoredUser {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1279 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1280 | impl From<RumaIgnoredUser> for IgnoredUser { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1281 | fn from(_value: RumaIgnoredUser) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1282 | IgnoredUser {} |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1283 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1284 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1285 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1286 | /// A push ruleset scopes a set of rules according to some criteria. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1287 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1288 | pub struct Ruleset { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1289 | /// These rules configure behavior for (unencrypted) messages that match |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1290 | /// certain patterns. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1291 | pub content: Vec<PatternedPushRule>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1292 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1293 | /// These user-configured rules are given the highest priority. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1294 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1295 | /// This field is named `override_` instead of `override` because the latter |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1296 | /// is a reserved keyword in Rust. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1297 | pub override_: Vec<ConditionalPushRule>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1298 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1299 | /// These rules change the behavior of all messages for a given room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1300 | pub room: Vec<SimplePushRule>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1301 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1302 | /// These rules configure notification behavior for messages from a specific |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1303 | /// Matrix user ID. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1304 | pub sender: Vec<SimplePushRule>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1305 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1306 | /// These rules are identical to override rules, but have a lower priority |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1307 | /// than `content`, `room` and `sender` rules. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1308 | pub underride: Vec<ConditionalPushRule>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1309 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1310 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1311 | impl TryFrom<RumaRuleset> for Ruleset { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1312 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1313 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1314 | fn try_from(value: RumaRuleset) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1315 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1316 | content: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1317 | .content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1318 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1319 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1320 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1321 | override_: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1322 | .override_ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1323 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1324 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1325 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1326 | room: value.room.into_iter().map(TryInto::try_into).collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1327 | sender: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1328 | .sender |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1329 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1330 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1331 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1332 | underride: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1333 | .underride |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1334 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1335 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1336 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1337 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1338 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1339 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1340 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1341 | /// Like [`SimplePushRule`], but with an additional `pattern`` field. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1342 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1343 | pub struct PatternedPushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1344 | /// Actions to determine if and how a notification is delivered for events |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1345 | /// matching this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1346 | pub actions: Vec<Action>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1347 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1348 | /// Whether this is a default rule, or has been set explicitly. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1349 | pub default: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1350 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1351 | /// Whether the push rule is enabled or not. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1352 | pub enabled: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1353 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1354 | /// The ID of this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1355 | pub rule_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1356 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1357 | /// The glob-style pattern to match against. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1358 | pub pattern: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1359 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1360 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1361 | impl TryFrom<RumaPatternedPushRule> for PatternedPushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1362 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1363 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1364 | fn try_from(value: RumaPatternedPushRule) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1365 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1366 | actions: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1367 | .actions |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1368 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1369 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1370 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1371 | default: value.default, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1372 | enabled: value.enabled, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1373 | rule_id: value.rule_id, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1374 | pattern: value.pattern, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1375 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1376 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1377 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1378 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1379 | /// Like [`SimplePushRule`], but with an additional `conditions` field. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1380 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1381 | pub struct ConditionalPushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1382 | /// Actions to determine if and how a notification is delivered for events |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1383 | /// matching this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1384 | pub actions: Vec<Action>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1385 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1386 | /// Whether this is a default rule, or has been set explicitly. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1387 | pub default: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1388 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1389 | /// Whether the push rule is enabled or not. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1390 | pub enabled: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1391 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1392 | /// The ID of this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1393 | pub rule_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1394 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1395 | /// The conditions that must hold true for an event in order for a rule to |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1396 | /// be applied to an event. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1397 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1398 | /// A rule with no conditions always matches. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1399 | pub conditions: Vec<PushCondition>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1400 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1401 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1402 | impl TryFrom<RumaConditionalPushRule> for ConditionalPushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1403 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1404 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1405 | fn try_from(value: RumaConditionalPushRule) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1406 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1407 | actions: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1408 | .actions |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1409 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1410 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1411 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1412 | default: value.default, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1413 | enabled: value.enabled, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1414 | rule_id: value.rule_id, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1415 | conditions: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1416 | .conditions |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1417 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1418 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1419 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1420 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1421 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1422 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1423 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1424 | /// A push rule is a single rule that states under what conditions an event |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1425 | /// should be passed onto a push gateway and how the notification should be |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1426 | /// presented. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1427 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1428 | pub struct SimplePushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1429 | /// Actions to determine if and how a notification is delivered for events |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1430 | /// matching this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1431 | pub actions: Vec<Action>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1432 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1433 | /// Whether this is a default rule, or has been set explicitly. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1434 | pub default: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1435 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1436 | /// Whether the push rule is enabled or not. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1437 | pub enabled: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1438 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1439 | /// The ID of this rule. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1440 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1441 | /// This is generally the Matrix ID of the entity that it applies to. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1442 | pub rule_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1443 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1444 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1445 | impl TryFrom<RumaSimplePushRule<OwnedRoomId>> for SimplePushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1446 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1447 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1448 | fn try_from(value: RumaSimplePushRule<OwnedRoomId>) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1449 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1450 | actions: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1451 | .actions |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1452 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1453 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1454 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1455 | default: value.default, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1456 | enabled: value.enabled, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1457 | rule_id: value.rule_id.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1458 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1459 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1460 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1461 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1462 | impl TryFrom<RumaSimplePushRule<OwnedUserId>> for SimplePushRule { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1463 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1464 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1465 | fn try_from(value: RumaSimplePushRule<OwnedUserId>) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1466 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1467 | actions: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1468 | .actions |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1469 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1470 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1471 | .collect::<Result<Vec<_>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1472 | default: value.default, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1473 | enabled: value.enabled, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1474 | rule_id: value.rule_id.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1475 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1476 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1477 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1478 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1479 | /// An algorithm and its properties, used to encrypt a secret. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1480 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1481 | pub enum SecretStorageEncryptionAlgorithm { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1482 | /// Encrypted using the `m.secret_storage.v1.aes-hmac-sha2` algorithm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1483 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1484 | /// Secrets using this method are encrypted using AES-CTR-256 and |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1485 | /// authenticated using HMAC-SHA-256. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1486 | V1AesHmacSha2 { properties: SecretStorageV1AesHmacSha2Properties }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1487 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1488 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1489 | impl TryFrom<RumaSecretStorageEncryptionAlgorithm> for SecretStorageEncryptionAlgorithm { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1490 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1491 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1492 | fn try_from(value: RumaSecretStorageEncryptionAlgorithm) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1493 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1494 | RumaSecretStorageEncryptionAlgorithm::V1AesHmacSha2(properties) => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1495 | Ok(Self::V1AesHmacSha2 { properties: properties.into() }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1496 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1497 | _ => Err("Unsupported encryption algorithm".to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1498 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1499 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1500 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1501 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1502 | /// The key properties for the `m.secret_storage.v1.aes-hmac-sha2`` algorithm. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1503 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1504 | pub struct SecretStorageV1AesHmacSha2Properties { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1505 | /// The 16-byte initialization vector, encoded as base64. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1506 | pub iv: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1507 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1508 | /// The MAC, encoded as base64. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1509 | pub mac: Option<String>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1510 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1511 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1512 | impl From<RumaSecretStorageV1AesHmacSha2Properties> for SecretStorageV1AesHmacSha2Properties { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1513 | fn from(value: RumaSecretStorageV1AesHmacSha2Properties) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1514 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1515 | iv: value.iv.map(|base64| base64.encode()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1516 | mac: value.mac.map(|base64| base64.encode()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1517 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1518 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1519 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1520 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1521 | /// The content of an `m.media_preview_config` event. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1522 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1523 | /// Is also the content of the unstable |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1524 | /// `io.element.msc4278.media_preview_config`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1525 | #[derive(Clone, uniffi::Record, Default)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1526 | pub struct MediaPreviewConfig { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1527 | /// The media previews setting for the user. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1528 | pub media_previews: Option<MediaPreviews>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1529 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1530 | /// The invite avatars setting for the user. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1531 | pub invite_avatars: Option<InviteAvatars>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1532 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1533 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1534 | impl From<MediaPreviewConfigEventContent> for MediaPreviewConfig { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1535 | fn from(value: MediaPreviewConfigEventContent) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1536 | Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1537 | media_previews: value.media_previews.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1538 | invite_avatars: value.invite_avatars.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1539 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1540 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1541 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1542 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1543 | /// A passphrase from which a key is to be derived. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1544 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1545 | pub struct PassPhrase { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1546 | /// The algorithm to use to generate the key from the passphrase. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1547 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1548 | /// Must be `m.pbkdf2`. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1549 | pub algorithm: KeyDerivationAlgorithm, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1550 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1551 | /// The salt used in PBKDF2. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1552 | pub salt: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1553 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1554 | /// The number of iterations to use in PBKDF2. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1555 | pub iterations: u64, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1556 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1557 | /// The number of bits to generate for the key. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1558 | /// |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1559 | /// Defaults to 256 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1560 | pub bits: u64, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1561 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1562 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1563 | impl TryFrom<RumaPassPhrase> for PassPhrase { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1564 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1565 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1566 | fn try_from(value: RumaPassPhrase) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1567 | Ok(PassPhrase { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1568 | algorithm: value.algorithm.try_into()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1569 | salt: value.salt, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1570 | iterations: value.iterations.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1571 | bits: value.bits.into(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1572 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1573 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1574 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1575 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1576 | /// A key algorithm to be used to generate a key from a passphrase. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1577 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1578 | pub enum KeyDerivationAlgorithm { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1579 | /// PBKDF2 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1580 | Pbkfd2, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1581 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1582 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1583 | impl TryFrom<RumaKeyDerivationAlgorithm> for KeyDerivationAlgorithm { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1584 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1585 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1586 | fn try_from(value: RumaKeyDerivationAlgorithm) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1587 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1588 | RumaKeyDerivationAlgorithm::Pbkfd2 => Ok(Self::Pbkfd2), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1589 | _ => Err("Unsupported key derivation algorithm".to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1590 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1591 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1592 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1593 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1594 | impl From<RumaGlobalAccountDataEvent<DirectEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1595 | fn from(value: RumaGlobalAccountDataEvent<DirectEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1596 | Self::Direct { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1597 | map: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1598 | .content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1599 | .0 |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1600 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1601 | .map(|(user_id, room_ids)| { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1602 | (user_id.to_string(), room_ids.iter().map(ToString::to_string).collect()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1603 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1604 | .collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1605 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1606 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1607 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1608 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1609 | impl From<RumaGlobalAccountDataEvent<IdentityServerEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1610 | fn from(value: RumaGlobalAccountDataEvent<IdentityServerEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1611 | Self::IdentityServer { base_url: value.content.base_url.into_option() } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1612 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1613 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1614 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1615 | impl From<RumaGlobalAccountDataEvent<IgnoredUserListEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1616 | fn from(value: RumaGlobalAccountDataEvent<IgnoredUserListEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1617 | Self::IgnoredUserList { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1618 | ignored_users: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1619 | .content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1620 | .ignored_users |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1621 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1622 | .map(|(user_id, ignored_user)| { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1623 | (user_id.to_string(), IgnoredUser::from(ignored_user)) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1624 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1625 | .collect(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1626 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1627 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1628 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1629 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1630 | impl TryFrom<RumaGlobalAccountDataEvent<PushRulesEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1631 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1632 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1633 | fn try_from( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1634 | value: RumaGlobalAccountDataEvent<PushRulesEventContent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1635 | ) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1636 | Ok(Self::PushRules { global: value.content.global.try_into()? }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1637 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1638 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1639 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1640 | impl From<RumaGlobalAccountDataEvent<SecretStorageDefaultKeyEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1641 | fn from(value: RumaGlobalAccountDataEvent<SecretStorageDefaultKeyEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1642 | Self::SecretStorageDefaultKey { key_id: value.content.key_id } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1643 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1644 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1645 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1646 | impl TryFrom<RumaGlobalAccountDataEvent<SecretStorageKeyEventContent>> for AccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1647 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1648 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1649 | fn try_from( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1650 | value: RumaGlobalAccountDataEvent<SecretStorageKeyEventContent>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1651 | ) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1652 | Ok(Self::SecretStorageKey { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1653 | key_id: value.content.key_id, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1654 | name: value.content.name, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1655 | algorithm: value.content.algorithm.try_into()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1656 | passphrase: value.content.passphrase.map(TryInto::try_into).transpose()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1657 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1658 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1659 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1660 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1661 | /// Types of room account data events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1662 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1663 | pub enum RoomAccountDataEventType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1664 | /// m.fully_read |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1665 | FullyRead, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1666 | /// m.marked_unread |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1667 | MarkedUnread, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1668 | /// m.tag |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1669 | Tag, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1670 | /// com.famedly.marked_unread |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1671 | UnstableMarkedUnread, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1672 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1673 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1674 | impl TryFrom<RumaRoomAccountDataEventType> for RoomAccountDataEventType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1675 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1676 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1677 | fn try_from(value: RumaRoomAccountDataEventType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1678 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1679 | RumaRoomAccountDataEventType::FullyRead => Ok(Self::FullyRead), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1680 | RumaRoomAccountDataEventType::MarkedUnread => Ok(Self::MarkedUnread), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1681 | RumaRoomAccountDataEventType::Tag => Ok(Self::Tag), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1682 | RumaRoomAccountDataEventType::UnstableMarkedUnread => Ok(Self::UnstableMarkedUnread), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1683 | _ => Err("Unsupported account data event type".to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1684 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1685 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1686 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1687 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1688 | /// Room account data events. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1689 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1690 | pub enum RoomAccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1691 | /// m.fully_read |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1692 | FullyReadEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1693 | /// The event the user's read marker is located at in the room. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1694 | event_id: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1695 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1696 | /// m.marked_unread |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1697 | MarkedUnread { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1698 | /// The current unread state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1699 | unread: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1700 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1701 | /// m.tag |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1702 | Tag { tags: HashMap<TagName, TagInfo> }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1703 | /// com.famedly.marked_unread |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1704 | UnstableMarkedUnread { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1705 | /// The current unread state. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1706 | unread: bool, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1707 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1708 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1709 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1710 | /// The name of a tag. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1711 | #[derive(Clone, PartialEq, Eq, Hash, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1712 | #[uniffi::export(Eq, Hash)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1713 | pub enum TagName { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1714 | /// `m.favourite`: The user's favorite rooms. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1715 | Favorite, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1716 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1717 | /// `m.lowpriority`: These should be shown with lower precedence than |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1718 | /// others. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1719 | LowPriority, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1720 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1721 | /// `m.server_notice`: Used to identify |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1722 | ServerNotice, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1723 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1724 | /// `u.*`: User-defined tag |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1725 | User { name: UserTagName }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1726 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1727 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1728 | impl TryFrom<RumaTagName> for TagName { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1729 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1730 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1731 | fn try_from(value: RumaTagName) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1732 | match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1733 | RumaTagName::Favorite => Ok(Self::Favorite), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1734 | RumaTagName::LowPriority => Ok(Self::LowPriority), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1735 | RumaTagName::ServerNotice => Ok(Self::ServerNotice), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1736 | RumaTagName::User(name) => Ok(Self::User { name: name.into() }), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1737 | _ => Err("Unsupported tag name".to_owned()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1738 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1739 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1740 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1741 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1742 | /// A user-defined tag name. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1743 | #[derive(Clone, PartialEq, Eq, Hash, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1744 | pub struct UserTagName { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1745 | name: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1746 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1747 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1748 | impl From<RumaUserTagName> for UserTagName { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1749 | fn from(value: RumaUserTagName) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1750 | Self { name: value.as_ref().to_owned() } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1751 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1752 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1753 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1754 | /// Information about a tag. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1755 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1756 | pub struct TagInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1757 | /// Value to use for lexicographically ordering rooms with this tag. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1758 | pub order: Option<f64>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1759 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1760 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1761 | impl From<RumaTagInfo> for TagInfo { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1762 | fn from(value: RumaTagInfo) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1763 | Self { order: value.order } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1764 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1765 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1766 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1767 | impl From<RumaRoomAccountDataEvent<FullyReadEventContent>> for RoomAccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1768 | fn from(value: RumaRoomAccountDataEvent<FullyReadEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1769 | Self::FullyReadEvent { event_id: value.content.event_id.into() } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1770 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1771 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1772 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1773 | impl From<RumaRoomAccountDataEvent<MarkedUnreadEventContent>> for RoomAccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1774 | fn from(value: RumaRoomAccountDataEvent<MarkedUnreadEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1775 | Self::MarkedUnread { unread: value.content.unread } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1776 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1777 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1778 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1779 | impl TryFrom<RumaRoomAccountDataEvent<TagEventContent>> for RoomAccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1780 | type Error = String; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1781 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1782 | fn try_from(value: RumaRoomAccountDataEvent<TagEventContent>) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1783 | Ok(Self::Tag { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1784 | tags: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1785 | .content |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1786 | .tags |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1787 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1788 | .map(|(name, info)| name.try_into().map(|name| (name, info.into()))) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1789 | .collect::<Result<HashMap<TagName, _>, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1790 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1791 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1792 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1793 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1794 | impl From<RumaRoomAccountDataEvent<UnstableMarkedUnreadEventContent>> for RoomAccountDataEvent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1795 | fn from(value: RumaRoomAccountDataEvent<UnstableMarkedUnreadEventContent>) -> Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1796 | Self::UnstableMarkedUnread { unread: value.content.unread } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1797 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1798 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1799 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1800 | #[cfg(feature = "unstable-msc4274")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1801 | pub use galleries::*; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1802 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1803 | #[cfg(feature = "unstable-msc4274")] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1804 | mod galleries { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1805 | use ruma::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1806 | events::room::message::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1807 | GalleryItemType as RumaGalleryItemType, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1808 | GalleryMessageEventContent as RumaGalleryMessageEventContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1809 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1810 | serde::JsonObject, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1811 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1812 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1813 | use crate::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1814 | error::ClientError, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1815 | ruma::{ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1816 | AudioMessageContent, FileMessageContent, FormattedBody, ImageMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1817 | VideoMessageContent, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1818 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1819 | }; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1820 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1821 | #[derive(Clone, uniffi::Record)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1822 | pub struct GalleryMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1823 | pub body: String, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1824 | pub formatted: Option<FormattedBody>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1825 | pub itemtypes: Vec<GalleryItemType>, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1826 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1827 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1828 | impl TryFrom<GalleryMessageContent> for RumaGalleryMessageEventContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1829 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1830 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1831 | fn try_from(value: GalleryMessageContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1832 | Ok(Self::new( |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1833 | value.body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1834 | value.formatted.map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1835 | value.itemtypes.into_iter().map(TryInto::try_into).collect::<Result<_, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1836 | )) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1837 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1838 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1839 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1840 | impl TryFrom<RumaGalleryMessageEventContent> for GalleryMessageContent { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1841 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1842 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1843 | fn try_from(value: RumaGalleryMessageEventContent) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1844 | Ok(Self { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1845 | body: value.body, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1846 | formatted: value.formatted.as_ref().map(Into::into), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1847 | itemtypes: value |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1848 | .itemtypes |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1849 | .into_iter() |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1850 | .map(TryInto::try_into) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1851 | .collect::<Result<_, _>>()?, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1852 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1853 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1854 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1855 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1856 | #[derive(Clone, uniffi::Enum)] |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1857 | pub enum GalleryItemType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1858 | Image { content: ImageMessageContent }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1859 | Audio { content: AudioMessageContent }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1860 | Video { content: VideoMessageContent }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1861 | File { content: FileMessageContent }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1862 | Other { itemtype: String, body: String }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1863 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1864 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1865 | impl TryFrom<GalleryItemType> for RumaGalleryItemType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1866 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1867 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1868 | fn try_from(value: GalleryItemType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1869 | Ok(match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1870 | GalleryItemType::Image { content } => Self::Image(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1871 | GalleryItemType::Audio { content } => Self::Audio(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1872 | GalleryItemType::Video { content } => Self::Video(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1873 | GalleryItemType::File { content } => Self::File(content.into()), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1874 | GalleryItemType::Other { itemtype, body } => { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1875 | Self::new(&itemtype, body, JsonObject::default())? |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1876 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1877 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1878 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1879 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1880 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1881 | impl TryFrom<RumaGalleryItemType> for GalleryItemType { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1882 | type Error = ClientError; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1883 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1884 | fn try_from(value: RumaGalleryItemType) -> Result<Self, Self::Error> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1885 | Ok(match value { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1886 | RumaGalleryItemType::Image(c) => GalleryItemType::Image { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1887 | RumaGalleryItemType::Audio(c) => GalleryItemType::Audio { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1888 | RumaGalleryItemType::Video(c) => GalleryItemType::Video { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1889 | RumaGalleryItemType::File(c) => GalleryItemType::File { content: c.try_into()? }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1890 | _ => GalleryItemType::Other { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1891 | itemtype: value.itemtype().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1892 | body: value.body().to_owned(), |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1893 | }, |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1894 | }) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1895 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1896 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1897 | } |