gnieto 6fd4b9b8b0
Properly serialize get_tags Response
`get_tags` route response was adding the `tags` property twice, which is
not the expected behaviour. This is an example of the previous
serialization of the `get_tags` route:

`{"tags":{"tags":{"u.example":{"order":0.55},"u.another":{"order":0.11}}}}`

The new serialization removes the outer `tags` property.
2020-07-05 13:20:47 +02:00

30 lines
817 B
Rust

//! Types for the *m.tag* event.
use std::collections::BTreeMap;
use ruma_events_macros::BasicEventContent;
use serde::{Deserialize, Serialize};
use crate::BasicEvent;
/// Informs the client of tags on a room.
pub type TagEvent = BasicEvent<TagEventContent>;
/// Map of tag names to tag info.
pub type Tags = BTreeMap<String, TagInfo>;
/// The payload for `TagEvent`.
#[derive(Clone, Debug, Deserialize, Serialize, BasicEventContent)]
#[ruma_event(type = "m.tag")]
pub struct TagEventContent {
/// A map of tag names to tag info.
pub tags: Tags,
}
/// Information about a tag.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TagInfo {
/// Value to use for lexicographically ordering rooms with this tag.
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<f64>,
}