diff options
| author | Nathan Perry <avaglir@gmail.com> | 2019-03-08 18:40:48 -0500 |
|---|---|---|
| committer | Nathan Perry <avaglir@gmail.com> | 2019-03-08 18:41:19 -0500 |
| commit | 87f10c3fb0c9f0d5794136124690bee5c5bef765 (patch) | |
| tree | 0906ddaac845ba0a6f5cf49ac5548cd8194042f3 /src/db/models.rs | |
| parent | a541f56b335fc66816205e034e97bfbf047ffaf7 (diff) | |
remove old oauth model and schema block
Diffstat (limited to 'src/db/models.rs')
| -rw-r--r-- | src/db/models.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/db/models.rs b/src/db/models.rs index 030daba..66e161a 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -284,46 +284,3 @@ impl InvocationRecord { .map_err(Error::from) } } - -#[derive(Queryable, Identifiable, PartialEq, Debug)] -#[table_name="google_oauth_tokens"] -pub struct GoogleOAuthToken { - pub id: i32, - pub token: String, - pub refresh_token: String, - pub expiration: NaiveDateTime, - pub created: NaiveDateTime, -} - -impl GoogleOAuthToken { - pub fn create(conn: &PgConnection, token: String, refresh_token: String, expiration: NaiveDateTime) -> Result<Self> { - ::diesel::insert_into(google_oauth_tokens::table) - .values(&NewGoogleOAuthToken { - token, - refresh_token, - expiration, - }) - .get_result::<GoogleOAuthToken>(conn) - .map_err(Error::from) - } - - pub fn latest(conn: &PgConnection) -> Result<Self> { - use chrono; - - let now = chrono::Utc::now().naive_utc(); - - google_oauth_tokens::table - .filter(google_oauth_tokens::expiration.gt(now)) - .order(google_oauth_tokens::created.desc()) - .first(conn) - .map_err(Error::from) - } -} - -#[derive(Insertable, PartialEq, Debug)] -#[table_name="google_oauth_tokens"] -pub struct NewGoogleOAuthToken { - pub token: String, - pub refresh_token: String, - pub expiration: NaiveDateTime, -} |
