diff --git a/src/profile/identity/gemini.rs b/src/profile/identity/gemini.rs index 51e36670..758e7405 100644 --- a/src/profile/identity/gemini.rs +++ b/src/profile/identity/gemini.rs @@ -21,7 +21,7 @@ impl Gemini { /// Create new `Self` pub fn new(connection: Rc>, profile_id: Rc) -> Self { Self { - auth: Rc::new(Auth::new(connection.clone(), profile_id.clone())), + auth: Rc::new(Auth::new(connection.clone())), database: Rc::new(Database::new(connection, profile_id)), } } diff --git a/src/profile/identity/gemini/auth.rs b/src/profile/identity/gemini/auth.rs index c409cda6..6f4342b3 100644 --- a/src/profile/identity/gemini/auth.rs +++ b/src/profile/identity/gemini/auth.rs @@ -5,7 +5,7 @@ use database::Database; use sqlite::{Connection, Transaction}; use std::{rc::Rc, sync::RwLock}; -/// API for `gemini_id` + `request` auth pairs operations +/// API for `profile_identity_gemini_id` + `url` auth pairs operations pub struct Auth { pub database: Rc, } @@ -14,9 +14,9 @@ impl Auth { // Constructors /// Create new `Self` - pub fn new(connection: Rc>, profile_id: Rc) -> Self { + pub fn new(connection: Rc>) -> Self { Self { - database: Rc::new(Database::new(connection, profile_id)), + database: Rc::new(Database::new(connection)), } } } diff --git a/src/profile/identity/gemini/auth/database.rs b/src/profile/identity/gemini/auth/database.rs index 8258a7ff..196aba61 100644 --- a/src/profile/identity/gemini/auth/database.rs +++ b/src/profile/identity/gemini/auth/database.rs @@ -4,25 +4,20 @@ use sqlite::{Connection, Error, Transaction}; pub struct Table { //pub id: i64, - //pub profile_id: i64, pub profile_identity_gemini_id: i64, } /// Storage for `profile_identity_gemini_id` + `url` auth pairs pub struct Database { connection: Rc>, - profile_id: Rc, // multi-profile relationship } impl Database { // Constructors /// Create new `Self` - pub fn new(connection: Rc>, profile_id: Rc) -> Self { - Self { - connection, - profile_id, - } + pub fn new(connection: Rc>) -> Self { + Self { connection } } // Getters @@ -31,7 +26,7 @@ impl Database { pub fn records(&self, url: Option<&str>) -> Result, Error> { let readable = self.connection.read().unwrap(); // @TODO let tx = readable.unchecked_transaction()?; - select(&tx, *self.profile_id, url) + select(&tx, url) } } @@ -42,16 +37,13 @@ pub fn init(tx: &Transaction) -> Result { "CREATE TABLE IF NOT EXISTS `profile_identity_gemini_auth` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - `profile_id` INTEGER NOT NULL, `profile_identity_gemini_id` INTEGER NOT NULL, `is_active` INTEGER NOT NULL, `url` VARCHAR(1024) NOT NULL, - FOREIGN KEY (`profile_id`) REFERENCES `profile`(`id`), FOREIGN KEY (`profile_identity_gemini_id`) REFERENCES `profile_identity_gemini`(`id`), UNIQUE ( - `profile_id`, `profile_identity_gemini_id`, `is_active`, `url` @@ -61,21 +53,19 @@ pub fn init(tx: &Transaction) -> Result { ) } -pub fn select(tx: &Transaction, profile_id: i64, url: Option<&str>) -> Result, Error> { +pub fn select(tx: &Transaction, url: Option<&str>) -> Result, Error> { let mut stmt = tx.prepare( "SELECT `id`, - `profile_id`, `profile_identity_gemini_id` FROM `profile_identity_gemini_auth` - WHERE `profile_id` = ? AND `url` LIKE ?", + WHERE `url` LIKE ?", )?; - let result = stmt.query_map((profile_id, url.unwrap_or("%")), |row| { + let result = stmt.query_map([url.unwrap_or("%")], |row| { Ok(Table { //id: row.get(0)?, - //profile_id: row.get(1)?, - profile_identity_gemini_id: row.get(2)?, + profile_identity_gemini_id: row.get(1)?, }) })?;