Skip to content

Commit

Permalink
sdk: move live location types into their own module
Browse files Browse the repository at this point in the history
  • Loading branch information
torrybr committed Sep 24, 2024
1 parent 2726e37 commit 7066fb3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions crates/matrix-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub use sliding_sync::{
#[cfg(feature = "uniffi")]
uniffi::setup_scaffolding!();

mod live_location;
#[cfg(any(test, feature = "testing"))]
pub mod test_utils;

Expand Down
21 changes: 21 additions & 0 deletions crates/matrix-sdk/src/live_location.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use ruma::{events::location::LocationContent, MilliSecondsSinceUnixEpoch, OwnedUserId};

/// Details of the last known location beacon.
#[derive(Clone, Debug)]
pub struct LastLocation {
/// The most recent location content of the user.
pub location: LocationContent,
/// The timestamp of when the location was updated
pub ts: MilliSecondsSinceUnixEpoch,
}

/// Details of a users live location share.
#[derive(Clone, Debug)]
pub struct LiveLocationShare {
/// The user's last known location.
pub last_location: LastLocation,
// /// Information about the associated beacon event (currently commented out).
// pub beacon_info: BeaconInfoEventContent,
/// The user ID of the person sharing their live location.
pub user_id: OwnedUserId,
}
27 changes: 3 additions & 24 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ use ruma::{
beacon_info::BeaconInfoEventContent,
call::notify::{ApplicationType, CallNotifyEventContent, NotifyType},
direct::DirectEventContent,
location::LocationContent,
marked_unread::MarkedUnreadEventContent,
receipt::{Receipt, ReceiptThread, ReceiptType},
room::{
Expand All @@ -87,9 +86,8 @@ use ruma::{
push::{Action, PushConditionRoomCtx},
serde::Raw,
time::Instant,
EventId, Int, MatrixToUri, MatrixUri, MilliSecondsSinceUnixEpoch, MxcUri, OwnedEventId,
OwnedRoomId, OwnedServerName, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UInt,
UserId,
EventId, Int, MatrixToUri, MatrixUri, MxcUri, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UInt, UserId,
};
use serde::de::DeserializeOwned;
use thiserror::Error;
Expand All @@ -110,6 +108,7 @@ use crate::{
error::{BeaconError, WrongRoomState},
event_cache::{self, EventCacheDropHandles, RoomEventCache},
event_handler::{EventHandler, EventHandlerDropGuard, EventHandlerHandle, SyncEvent},
live_location::{LastLocation, LiveLocationShare},
media::{MediaFormat, MediaRequest},
notification_settings::{IsEncrypted, IsOneToOne, RoomNotificationMode},
room::power_levels::{RoomPowerLevelChanges, RoomPowerLevelsExt},
Expand Down Expand Up @@ -3019,26 +3018,6 @@ impl Room {
}
}

/// Details of the last known location beacon.
#[derive(Clone, Debug)]
pub struct LastLocation {
/// The most recent location content of the user.
pub location: LocationContent,
/// The timestamp of when the location was updated
pub ts: MilliSecondsSinceUnixEpoch,
}

/// Details of a users live location share.
#[derive(Clone, Debug)]
pub struct LiveLocationShare {
/// The user's last known location.
pub last_location: LastLocation,
// /// Information about the associated beacon event (currently commented out).
// pub beacon_info: BeaconInfoEventContent,
/// The user ID of the person sharing their live location.
pub user_id: OwnedUserId,
}

/// A wrapper for a weak client and a room id that allows to lazily retrieve a
/// room, only when needed.
#[derive(Clone)]
Expand Down

0 comments on commit 7066fb3

Please sign in to comment.