mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Add available_reactions
field to Chat
This commit is contained in:
parent
409c3d5403
commit
1e25bf1c96
3 changed files with 53 additions and 4 deletions
|
@ -1,7 +1,8 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{
|
||||
ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, Seconds, True, User,
|
||||
ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, ReactionType, Seconds,
|
||||
True, User,
|
||||
};
|
||||
|
||||
/// This object represents a chat.
|
||||
|
@ -21,6 +22,12 @@ pub struct Chat {
|
|||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub photo: Option<ChatPhoto>,
|
||||
|
||||
/// List of available reactions allowed in the chat. If omitted, then all
|
||||
/// emoji reactions are allowed. Returned only from [`GetChat`].
|
||||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub available_reactions: Option<Vec<ReactionType>>,
|
||||
|
||||
/// The most recent pinned message (by sending date). Returned only in
|
||||
/// [`GetChat`].
|
||||
///
|
||||
|
@ -602,13 +609,29 @@ mod tests {
|
|||
has_protected_content: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: Some(vec![ReactionType {
|
||||
kind: ReactionTypeKind::Emoji { emoji: "🌭".to_owned() },
|
||||
}]),
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
has_aggressive_anti_spam_enabled: false,
|
||||
chat_full_info: ChatFullInfo::default(),
|
||||
};
|
||||
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channel_name"}"#).unwrap();
|
||||
let actual = from_str(
|
||||
r#"{
|
||||
"id": -1,
|
||||
"type": "channel",
|
||||
"username": "channel_name",
|
||||
"available_reactions": [
|
||||
{
|
||||
"type": "emoji",
|
||||
"emoji": "🌭"
|
||||
}
|
||||
]
|
||||
}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -626,14 +649,30 @@ mod tests {
|
|||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: Some(vec![ReactionType {
|
||||
kind: ReactionTypeKind::Emoji { emoji: "🌭".to_owned() },
|
||||
}]),
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
has_aggressive_anti_spam_enabled: false,
|
||||
chat_full_info: ChatFullInfo::default()
|
||||
},
|
||||
from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#)
|
||||
.unwrap()
|
||||
from_str(
|
||||
r#"{
|
||||
"id": 0,
|
||||
"type": "private",
|
||||
"username": "username",
|
||||
"first_name": "Anon",
|
||||
"available_reactions": [
|
||||
{
|
||||
"type": "emoji",
|
||||
"emoji": "🌭"
|
||||
}
|
||||
]
|
||||
}"#
|
||||
)
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -650,6 +689,7 @@ mod tests {
|
|||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
|
|
@ -1841,6 +1841,7 @@ mod tests {
|
|||
has_restricted_voice_and_video_messages: None
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
has_aggressive_anti_spam_enabled: false,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
|
@ -2078,6 +2079,7 @@ mod tests {
|
|||
}),
|
||||
message_auto_delete_time: None,
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
has_hidden_members: false,
|
||||
has_aggressive_anti_spam_enabled: false,
|
||||
|
@ -2368,6 +2370,7 @@ mod tests {
|
|||
has_protected_content: None
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
@ -2476,6 +2479,7 @@ mod tests {
|
|||
has_protected_content: None
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
@ -2498,6 +2502,7 @@ mod tests {
|
|||
has_protected_content: None
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
@ -2598,6 +2603,7 @@ mod tests {
|
|||
has_protected_content: None
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
|
|
@ -482,6 +482,7 @@ mod test {
|
|||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
@ -829,6 +830,7 @@ mod test {
|
|||
has_protected_content: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
@ -908,6 +910,7 @@ mod test {
|
|||
has_protected_content: None,
|
||||
}),
|
||||
photo: None,
|
||||
available_reactions: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_hidden_members: false,
|
||||
|
|
Loading…
Reference in a new issue