mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-11 04:21:12 +01:00
Move Chat::has_protected_content
to ChatPublic
This commit is contained in:
parent
22159867bb
commit
488492e9e5
3 changed files with 21 additions and 12 deletions
|
@ -34,12 +34,6 @@ pub struct Chat {
|
|||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
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]
|
||||
|
@ -76,6 +70,12 @@ pub struct ChatPublic {
|
|||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub invite_link: Option<String>,
|
||||
|
||||
/// `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]
|
||||
|
@ -395,6 +395,17 @@ impl Chat {
|
|||
}
|
||||
}
|
||||
|
||||
/// `True`, if messages from the chat can't be forwarded to other chats.
|
||||
/// Returned only in [`GetChat`].
|
||||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub fn has_protected_content(&self) -> Option<True> {
|
||||
match &self.kind {
|
||||
ChatKind::Public(this) => this.has_protected_content,
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A first name of the other party in a private chat.
|
||||
pub fn first_name(&self) -> Option<&str> {
|
||||
match &self.kind {
|
||||
|
@ -452,11 +463,11 @@ mod tests {
|
|||
}),
|
||||
description: None,
|
||||
invite_link: None,
|
||||
has_protected_content: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_protected_content: None,
|
||||
};
|
||||
let actual = from_str(r#"{"id":-1,"type":"channel","username":"channelname"}"#).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
|
@ -473,12 +484,11 @@ mod tests {
|
|||
first_name: Some("Anon".into()),
|
||||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None
|
||||
has_private_forwards: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_protected_content: None,
|
||||
},
|
||||
from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#)
|
||||
.unwrap()
|
||||
|
|
|
@ -1339,11 +1339,11 @@ mod tests {
|
|||
}),
|
||||
description: None,
|
||||
invite_link: None,
|
||||
has_protected_content: None,
|
||||
}),
|
||||
message_auto_delete_time: None,
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_protected_content: None,
|
||||
};
|
||||
|
||||
assert!(message.from().unwrap().is_anonymous());
|
||||
|
|
|
@ -198,7 +198,6 @@ mod test {
|
|||
photo: None,
|
||||
pinned_message: None,
|
||||
message_auto_delete_time: None,
|
||||
has_protected_content: None,
|
||||
},
|
||||
kind: MessageKind::Common(MessageCommon {
|
||||
from: Some(User {
|
||||
|
|
Loading…
Reference in a new issue