use ruma_common::OwnedRoomId;
use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::{
EmptyStateKey, EventContent, PossiblyRedactedStateEventContent, StateEventType,
StaticEventContent,
};
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(
type = "m.room.tombstone",
kind = State,
state_key_type = EmptyStateKey,
custom_possibly_redacted,
)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct RoomTombstoneEventContent {
#[cfg_attr(feature = "compat-optional", serde(default))]
pub body: String,
pub replacement_room: OwnedRoomId,
}
impl RoomTombstoneEventContent {
pub fn new(body: String, replacement_room: OwnedRoomId) -> Self {
Self { body, replacement_room }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct PossiblyRedactedRoomTombstoneEventContent {
pub body: Option<String>,
pub replacement_room: Option<OwnedRoomId>,
}
impl EventContent for PossiblyRedactedRoomTombstoneEventContent {
type EventType = StateEventType;
fn event_type(&self) -> Self::EventType {
StateEventType::RoomTombstone
}
}
impl PossiblyRedactedStateEventContent for PossiblyRedactedRoomTombstoneEventContent {
type StateKey = EmptyStateKey;
}
impl StaticEventContent for PossiblyRedactedRoomTombstoneEventContent {
const TYPE: &'static str = "m.room.tombstone";
}