Expose iOS copy payload API
This commit is contained in:
@@ -218,6 +218,20 @@ impl<C: TdClientTrait> CoreSession<C> {
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub async fn copy_payload(
|
||||
&mut self,
|
||||
chat_id: ChatId,
|
||||
message_id: MessageId,
|
||||
) -> Result<String, String> {
|
||||
self.client
|
||||
.get_chat_history(chat_id, i32::MAX)
|
||||
.await?
|
||||
.into_iter()
|
||||
.find(|message| message.id() == message_id)
|
||||
.map(|message| message.text().to_string())
|
||||
.ok_or_else(|| "message not found".to_string())
|
||||
}
|
||||
|
||||
pub async fn open_profile(&mut self, chat_id: ChatId) -> Result<CoreProfile, String> {
|
||||
let profile = self
|
||||
.client
|
||||
@@ -871,6 +885,10 @@ mod tests {
|
||||
.edit_text_message(chat_id, MessageId::new(10), "After".to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
let copied = session
|
||||
.copy_payload(chat_id, MessageId::new(10))
|
||||
.await
|
||||
.unwrap();
|
||||
session
|
||||
.delete_messages(chat_id, vec![MessageId::new(10)], true)
|
||||
.await
|
||||
@@ -878,6 +896,7 @@ mod tests {
|
||||
|
||||
assert_eq!(sent.text, "Hello");
|
||||
assert_eq!(edited.text, "After");
|
||||
assert_eq!(copied, "After");
|
||||
assert_eq!(
|
||||
session.poll_events(),
|
||||
vec![
|
||||
|
||||
Reference in New Issue
Block a user