1use ruma_common::{MilliSecondsSinceUnixEpoch, OwnedEventId};
7use ruma_events::{location::LocationContent, relation::Reference};
8use ruma_macros::EventContent;
9use serde::{Deserialize, Serialize};
10
11#[derive(Clone, Debug, Serialize, Deserialize, EventContent)]
13#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
14#[ruma_event(type = "org.matrix.msc3672.beacon", alias = "m.beacon", kind = MessageLike)]
15pub struct BeaconEventContent {
16 #[serde(rename = "m.relates_to")]
18 pub relates_to: Reference,
19
20 #[serde(rename = "org.matrix.msc3488.location")]
22 pub location: LocationContent,
23
24 #[serde(rename = "org.matrix.msc3488.ts")]
26 pub ts: MilliSecondsSinceUnixEpoch,
27}
28
29impl BeaconEventContent {
30 pub fn new(
33 beacon_info_event_id: OwnedEventId,
34 geo_uri: String,
35 ts: Option<MilliSecondsSinceUnixEpoch>,
36 ) -> Self {
37 Self {
38 relates_to: Reference::new(beacon_info_event_id),
39 location: LocationContent::new(geo_uri),
40 ts: ts.unwrap_or_else(MilliSecondsSinceUnixEpoch::now),
41 }
42 }
43}