Add Chat::has_protected_content

This commit is contained in:
Maybe Waffle 2022-01-11 15:38:42 +03:00
parent 4af317e1fd
commit 22159867bb
4 changed files with 13 additions and 2 deletions

View file

@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ApiError::TooMuchInlineQueryResults` ([#135][pr135]) - `ApiError::TooMuchInlineQueryResults` ([#135][pr135])
- `ApiError::NotEnoughRightsToChangeChatPermissions` ([#155][pr155]) - `ApiError::NotEnoughRightsToChangeChatPermissions` ([#155][pr155])
- Support for 5.4 telegram bot API ([#133][pr133]) - Support for 5.4 telegram bot API ([#133][pr133])
- Support for 5.5 telegram bot API ([#143][pr143]) - Support for 5.5 telegram bot API ([#143][pr143], [#164][pr164])
- `EditedMessageIsTooLong` error ([#109][pr109]) - `EditedMessageIsTooLong` error ([#109][pr109])
- `UntilDate` enum and use it for `{Restricted, Banned}::until_date` ([#116][pr116]) - `UntilDate` enum and use it for `{Restricted, Banned}::until_date` ([#116][pr116])
- `Limits::messages_per_min_channel` ([#121][pr121]) - `Limits::messages_per_min_channel` ([#121][pr121])
@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[pr143]: https://github.com/teloxide/teloxide-core/pull/143 [pr143]: https://github.com/teloxide/teloxide-core/pull/143
[pr151]: https://github.com/teloxide/teloxide-core/pull/151 [pr151]: https://github.com/teloxide/teloxide-core/pull/151
[pr155]: https://github.com/teloxide/teloxide-core/pull/155 [pr155]: https://github.com/teloxide/teloxide-core/pull/155
[pr164]: https://github.com/teloxide/teloxide-core/pull/164
### Changed ### Changed

View file

@ -34,6 +34,12 @@ pub struct Chat {
/// ///
/// [`GetChat`]: crate::payloads::GetChat /// [`GetChat`]: crate::payloads::GetChat
pub message_auto_delete_time: Option<u32>, pub message_auto_delete_time: Option<u32>,
/// `true`, if messages from the chat can't be forwarded to other chats.
/// Returned only in [`GetChat`].
///
/// [`GetChat`]: crate::payloads::GetChat
pub has_protected_content: Option<True>,
} }
#[serde_with_macros::skip_serializing_none] #[serde_with_macros::skip_serializing_none]
@ -97,7 +103,7 @@ pub struct ChatPrivate {
pub bio: Option<String>, pub bio: Option<String>,
/// `True`, if privacy settings of the other party in the private chat /// `True`, if privacy settings of the other party in the private chat
/// allows to use tg://user?id=<user_id> links only in chats with the /// allows to use `tg://user?id=<user_id>` links only in chats with the
/// user. Returned only in [`GetChat`]. /// user. Returned only in [`GetChat`].
/// ///
/// [`GetChat`]: crate::payloads::GetChat /// [`GetChat`]: crate::payloads::GetChat
@ -450,6 +456,7 @@ mod tests {
photo: None, photo: None,
pinned_message: None, pinned_message: None,
message_auto_delete_time: None, message_auto_delete_time: None,
has_protected_content: None,
}; };
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#).unwrap(); let actual = from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#).unwrap();
assert_eq!(expected, actual); assert_eq!(expected, actual);
@ -471,6 +478,7 @@ mod tests {
photo: None, photo: None,
pinned_message: None, pinned_message: None,
message_auto_delete_time: None, message_auto_delete_time: None,
has_protected_content: None,
}, },
from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#) from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#)
.unwrap() .unwrap()

View file

@ -1343,6 +1343,7 @@ mod tests {
photo: None, photo: None,
pinned_message: None, pinned_message: None,
message_auto_delete_time: None, message_auto_delete_time: None,
has_protected_content: None,
}; };
assert!(message.from().unwrap().is_anonymous()); assert!(message.from().unwrap().is_anonymous());

View file

@ -198,6 +198,7 @@ mod test {
photo: None, photo: None,
pinned_message: None, pinned_message: None,
message_auto_delete_time: None, message_auto_delete_time: None,
has_protected_content: None,
}, },
kind: MessageKind::Common(MessageCommon { kind: MessageKind::Common(MessageCommon {
from: Some(User { from: Some(User {