use ruma_common::{MilliSecondsSinceUnixEpoch, OwnedEventId};
use ruma_events::{location::LocationContent, relation::Reference};
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, EventContent)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
#[ruma_event(type = "org.matrix.msc3672.beacon", alias = "m.beacon", kind = MessageLike)]
pub struct BeaconEventContent {
#[serde(rename = "m.relates_to")]
pub relates_to: Reference,
#[serde(rename = "org.matrix.msc3488.location")]
pub location: LocationContent,
#[serde(rename = "org.matrix.msc3488.ts")]
pub ts: MilliSecondsSinceUnixEpoch,
}
impl BeaconEventContent {
pub fn new(
beacon_info_event_id: OwnedEventId,
geo_uri: String,
ts: Option<MilliSecondsSinceUnixEpoch>,
) -> Self {
Self {
relates_to: Reference::new(beacon_info_event_id),
location: LocationContent::new(geo_uri),
ts: ts.unwrap_or_else(MilliSecondsSinceUnixEpoch::now),
}
}
}