use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};
use crate::serde::Base64;
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[ruma_event(type = "m.room.third_party_invite", kind = State, state_key_type = String)]
pub struct RoomThirdPartyInviteEventContent {
#[cfg_attr(feature = "compat", serde(default))]
pub display_name: String,
#[cfg_attr(feature = "compat", serde(default))]
pub key_validity_url: String,
#[cfg_attr(feature = "compat", serde(default = "Base64::empty"))]
pub public_key: Base64,
#[serde(skip_serializing_if = "Option::is_none")]
pub public_keys: Option<Vec<PublicKey>>,
}
impl RoomThirdPartyInviteEventContent {
pub fn new(display_name: String, key_validity_url: String, public_key: Base64) -> Self {
Self { display_name, key_validity_url, public_key, public_keys: None }
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct PublicKey {
#[serde(skip_serializing_if = "Option::is_none")]
pub key_validity_url: Option<String>,
pub public_key: Base64,
}
impl PublicKey {
pub fn new(public_key: Base64) -> Self {
Self { key_validity_url: None, public_key }
}
}