twitter_archive/structs/
follow.rs

1#!/usr/bin/env rust
2
3//! Tweeter archives as of 2023-08-31 have private data found under;
4//!
5//!   twitter-<DATE>-<UID>.zip:data/following.js
6//!   twitter-<DATE>-<UID>.zip:data/follower.js
7//!
8//! Check following source code files for example usage;
9//!
10//! - ./follower.rs
11//! - ./following.rs
12//!
13//! ## Example `twitter-<DATE>-<UID>.zip:data/following.js` content
14//!
15//! ```javascript
16//! window.YTD.following.part0 = [
17//!   {
18//!     "following" : {
19//!       "accountId" : "1111111111111111111",
20//!       "userLink" : "https://twitter.com/intent/user?user_id=1111111111111111111"
21//!     }
22//!   }
23//! ]
24//! ```
25//!
26//! ## Example `twitter-<DATE>-<UID>.zip:data/follower.js` content
27//!
28//! ```javascript
29//! window.YTD.follower.part0 = [
30//!   {
31//!     "follower" : {
32//!       "accountId" : "2222222222222222222",
33//!       "userLink" : "https://twitter.com/intent/user?user_id=2222222222222222222"
34//!     }
35//!   }
36//! ]
37//! ```
38
39use derive_more::Display;
40use serde::{Deserialize, Serialize};
41
42/// ## Example
43///
44/// ```
45/// use twitter_archive::structs::follow::Follow;
46///
47/// let json = r#"{
48///   "accountId": "2222222222222222222",
49///   "userLink": "https://twitter.com/intent/user?user_id=2222222222222222222"
50/// }"#;
51///
52/// let data: Follow = serde_json::from_str(&json).unwrap();
53///
54/// // De-serialized properties
55/// assert_eq!(data.account_id, "2222222222222222222");
56/// assert_eq!(data.user_link, "https://twitter.com/intent/user?user_id=2222222222222222222");
57///
58/// // Re-serialize is equivalent to original data
59/// assert_eq!(serde_json::to_string_pretty(&data).unwrap(), json);
60/// ```
61#[derive(Deserialize, Serialize, Debug, Clone, Display)]
62#[display(fmt = "{}", "serde_json::to_value(self).unwrap()")]
63#[serde(rename_all = "camelCase")]
64pub struct Follow {
65	/// URL formats;
66	///
67	/// - Desktop: https://twitter.com/i/user/{account_id}
68	///
69	/// > Note; does **not** work if not logged-in.  Thanks be to Mr. Musk !-D
70	///
71	/// ## Example JSON data
72	///
73	/// ```json
74	/// { "accountId": "2222222222222222222" }
75	/// ```
76	pub account_id: String,
77
78	/// Alternate way of directly linking to account by ID, with added side effect of prompting
79	/// client to follow profile regardless of following status
80	///
81	/// ## Example JSON data
82	///
83	/// ```json
84	/// { "userLink": "https://twitter.com/intent/user?user_id=2222222222222222222" }
85	/// ```
86	pub user_link: String,
87}