refactor(webapi): hoist RoomMetadata to blah_types and rename last_chat to last_item

This commit is contained in:
oxalica 2024-09-10 09:19:15 -04:00
parent c0ec429c24
commit 74c6fa6f6a
5 changed files with 40 additions and 33 deletions

View file

@ -308,6 +308,29 @@ impl RichText {
pub type ChatItem = WithSig<ChatPayload>;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RoomMetadata {
/// Room id.
pub rid: Id,
/// Plain text room title.
pub title: String,
/// Room attributes.
pub attrs: RoomAttrs,
// Extra information is only available for some APIs.
/// The last item in the room.
#[serde(skip_serializing_if = "Option::is_none")]
pub last_item: Option<WithItemId<ChatItem>>,
/// The current user's last seen item id.
#[serde(skip_serializing_if = "Option::is_none")]
pub last_seen_cid: Option<Id>,
/// The number of unseen messages, ie. the number of items from `last_seen_cid` to
/// `last_item.cid`.
/// This may or may not be a precise number.
#[serde(skip_serializing_if = "Option::is_none")]
pub unseen_cnt: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "typ", rename = "create_room")]
pub struct CreateRoomPayload {