events: Add compat feature to send empty string to unset room name
This commit is contained in:
parent
f266ea90e7
commit
6da56dc541
@ -48,6 +48,10 @@ compat-empty-string-null = []
|
||||
# mandatory. Deserialization will yield a default value like an empty string.
|
||||
compat-optional = []
|
||||
|
||||
# Unset the room name by sending an empty string,
|
||||
# c.f. https://github.com/matrix-org/matrix-spec/issues/1632
|
||||
compat-unset-room-name = []
|
||||
|
||||
# Allow TagInfo to contain a stringified floating-point value for the `order` field.
|
||||
compat-tag-info = []
|
||||
|
||||
|
@ -15,7 +15,19 @@ use crate::EmptyStateKey;
|
||||
#[ruma_event(type = "m.room.name", kind = State, state_key_type = EmptyStateKey)]
|
||||
pub struct RoomNameEventContent {
|
||||
/// The name of the room.
|
||||
///
|
||||
/// If you activate the `compat-unset-room-name` feature, this field being `None` will result
|
||||
/// in an empty string in serialization, (c.f.
|
||||
/// <https://github.com/matrix-org/matrix-spec/issues/1632>).
|
||||
#[serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none")]
|
||||
#[cfg_attr(
|
||||
feature = "compat-unset-room-name",
|
||||
serde(serialize_with = "ruma_common::serde::none_as_empty_string")
|
||||
)]
|
||||
#[cfg_attr(
|
||||
not(feature = "compat-unset-room-name"),
|
||||
serde(skip_serializing_if = "Option::is_none")
|
||||
)]
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,9 @@ compat-optional = ["ruma-common/compat-optional"]
|
||||
# Unset avatars by sending an empty string, same as what Element Web does, c.f.
|
||||
# https://github.com/matrix-org/matrix-spec/issues/378#issuecomment-1055831264
|
||||
compat-unset-avatar = ["ruma-client-api?/compat-unset-avatar"]
|
||||
# Unset the room name by sending an empty string,
|
||||
# c.f. https://github.com/matrix-org/matrix-spec/issues/1632
|
||||
compat-unset-room-name = ["ruma-events?/compat-unset-room-name"]
|
||||
# Always serialize the threepids response field in `get_3pids::v3::Response`,
|
||||
# even if its value is an empty list.
|
||||
compat-get-3pids = ["ruma-client-api?/compat-get-3pids"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user