1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
use crate::schema::*; #[derive(Clone, Debug, Identifiable, Queryable)] #[table_name = "last_tweet"] pub struct LastTweet { pub id: i64, pub status_id: i64, } #[derive(Clone, Debug, Insertable)] #[table_name = "last_tweet"] pub struct NewLastTweet { pub id: i64, pub status_id: i64, } #[derive(Clone, Debug, Identifiable, Queryable)] pub struct Tweet { pub id: i64, pub text: String, pub user_id: i64, pub in_reply_to_status_id: Option<i64>, pub quoted_status_id: Option<i64>, pub quoted_status_text: Option<String>, } #[derive(Clone, Debug, Insertable)] #[table_name = "tweets"] pub struct NewTweet<'a> { pub id: i64, pub text: &'a str, pub user_id: i64, pub in_reply_to_status_id: Option<i64>, pub quoted_status_id: Option<i64>, } #[derive(Clone, Debug, Identifiable, Queryable)] pub struct TwitterToken { pub id: i64, pub access_token: String, pub access_token_secret: String, } #[derive(Clone, Debug, Insertable)] #[table_name = "twitter_tokens"] pub struct NewTwitterTokens<'a> { pub id: i64, pub access_token: &'a str, pub access_token_secret: &'a str, } impl From<TwitterToken> for oauth1::Credentials<Box<str>> { fn from(token: TwitterToken) -> Self { Self { identifier: token.access_token.into(), secret: token.access_token_secret.into(), } } } impl From<TwitterToken> for oauth1::Credentials { fn from(token: TwitterToken) -> Self { Self { identifier: token.access_token, secret: token.access_token_secret, } } } impl<'a> From<&'a TwitterToken> for oauth1::Credentials<&'a str> { fn from(token: &'a TwitterToken) -> Self { Self { identifier: &token.access_token, secret: &token.access_token_secret, } } } impl<'a> From<&'a crate::twitter::Tweet> for NewTweet<'a> { fn from(tweet: &'a crate::twitter::Tweet) -> Self { NewTweet { id: tweet.id, text: &tweet.text, user_id: tweet.user.id, in_reply_to_status_id: tweet.in_reply_to_status_id, quoted_status_id: tweet.quoted_status.as_ref().map(|q| q.id), } } }