pub struct MessageCreate {
pub recipient_id: String,
pub reactions: Vec<MessageCreateReaction>,
pub urls: Vec<MessageCreateUrl>,
pub text: String,
pub media_urls: Vec<String>,
pub sender_id: String,
pub id: String,
pub created_at: DateTime<Utc>,
}Expand description
Note, other than the addition of a recipient_id (recipientId) key, this is identical to
MessageCreate from twitter_archive::structs::direct_messages_group
§Example
use chrono::{DateTime, NaiveDateTime, Utc};
use twitter_archive::structs::direct_messages::MessageCreate;
use twitter_archive::convert::date_time_iso_8601::FORMAT;
let created_at_string = "2020-01-20T21:42:09.068Z";
let created_at_native_time = NaiveDateTime::parse_from_str(&created_at_string, FORMAT).unwrap();
let created_at_date_time = DateTime::<Utc>::from_naive_utc_and_offset(created_at_native_time, Utc);
let json = format!(r#"{{
"recipientId": "222222222",
"reactions": [],
"urls": [],
"text": "Salutations!",
"mediaUrls": [],
"senderId": "111111111",
"id": "3333333333333333333",
"createdAt": "{created_at_string}"
}}"#);
let data: MessageCreate = serde_json::from_str(&json).unwrap();
// De-serialized properties
assert_eq!(data.recipient_id, "222222222");
assert_eq!(data.reactions.len(), 0);
assert_eq!(data.urls.len(), 0);
assert_eq!(data.media_urls.len(), 0);
assert_eq!(data.sender_id, "111111111");
assert_eq!(data.id, "3333333333333333333");
assert_eq!(data.created_at, created_at_date_time);
// Re-serialize is equivalent to original data
assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);Fields§
§recipient_id: StringURL formats;
- Desktop: https://twitter.com/i/user/{recipient_id}
Note; does not work if not logged-in. Thanks be to Mr. Musk !-D
§Example JSON data
{ "recipientId": "222222222" }reactions: Vec<MessageCreateReaction>List data about who, when, and what reactions were had about a given message
§Example JSON data
{ "reactions": [] }urls: Vec<MessageCreateUrl>List of mangled/tracking URL data that includes originally written link too
§Example JSON data
{ "urls": [] }text: StringContent of message with embedded newlines \n where applicable
§Example JSON data
{ "text": "Salutations!" }media_urls: Vec<String>Finally a simple array of strings without unnecessary modifications or parsing required!
§Example JSON data
{ "mediaUrls": [] }sender_id: StringURL formats;
- Desktop: https://twitter.com/i/user/{sender_id}
Note; does not work if not logged-in. Thanks be to Mr. Musk !-D
§Example JSON data
{ "senderId": "111111111" }id: StringPossibly unique ID across all conversations and messages
Report url maybe built via; https://twitter.com/i/report/dm_message/{id}
§Example JSON data
{ "id": "3333333333333333333" }created_at: DateTime<Utc>Date time-stamp of when message was originally sent
§Example JSON data
{ "createdAt": "2020-01-20T21:42:09.068Z" }Trait Implementations§
Source§impl Clone for MessageCreate
impl Clone for MessageCreate
Source§fn clone(&self) -> MessageCreate
fn clone(&self) -> MessageCreate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more