summaryrefslogtreecommitdiff
path: root/src/repo
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-17 19:06:20 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-17 19:06:20 -0400
commit921f38a73e5d58a5a6077477a8b52d2705798f55 (patch)
tree895eee6c31a9e6003e4d199e32eb04bcb32f8f11 /src/repo
parente6be82157fe718570aa13ab12803ee39083b8dff (diff)
Express record dependencies through types.
This provides a convenient place to _stick_ "not found" errors, though actually introducing them will come in a later commit.
Diffstat (limited to 'src/repo')
-rw-r--r--src/repo/channel.rs2
-rw-r--r--src/repo/login/mod.rs2
-rw-r--r--src/repo/login/store.rs18
-rw-r--r--src/repo/token.rs4
4 files changed, 4 insertions, 22 deletions
diff --git a/src/repo/channel.rs b/src/repo/channel.rs
index ab7489c..8e3a471 100644
--- a/src/repo/channel.rs
+++ b/src/repo/channel.rs
@@ -43,7 +43,7 @@ impl<'c> Channels<'c> {
Ok(channel)
}
- pub async fn by_id(&mut self, channel: Id) -> Result<Channel, sqlx::Error> {
+ pub async fn by_id(&mut self, channel: &Id) -> Result<Channel, sqlx::Error> {
let channel = sqlx::query_as!(
Channel,
r#"
diff --git a/src/repo/login/mod.rs b/src/repo/login/mod.rs
index e23a7b7..a1b4c6f 100644
--- a/src/repo/login/mod.rs
+++ b/src/repo/login/mod.rs
@@ -1,4 +1,4 @@
mod extract;
mod store;
-pub use self::store::{Id, Login, Logins, Provider};
+pub use self::store::{Id, Login, Provider};
diff --git a/src/repo/login/store.rs b/src/repo/login/store.rs
index 24dd744..d979579 100644
--- a/src/repo/login/store.rs
+++ b/src/repo/login/store.rs
@@ -54,24 +54,6 @@ impl<'c> Logins<'c> {
Ok(login)
}
-
- pub async fn by_id(&mut self, id: &Id) -> Result<Login, sqlx::Error> {
- let login = sqlx::query_as!(
- Login,
- r#"
- select
- id as "id: Id",
- name
- from login
- where id = $1
- "#,
- id,
- )
- .fetch_one(&mut *self.0)
- .await?;
-
- Ok(login)
- }
}
impl<'t> From<&'t mut SqliteConnection> for Logins<'t> {
diff --git a/src/repo/token.rs b/src/repo/token.rs
index e7eb273..01a982e 100644
--- a/src/repo/token.rs
+++ b/src/repo/token.rs
@@ -22,7 +22,7 @@ impl<'c> Tokens<'c> {
/// be used to control expiry, until the token is actually used.
pub async fn issue(
&mut self,
- login: &login::Id,
+ login: &Login,
issued_at: DateTime,
) -> Result<String, sqlx::Error> {
let secret = Uuid::new_v4().to_string();
@@ -35,7 +35,7 @@ impl<'c> Tokens<'c> {
returning secret as "secret!"
"#,
secret,
- login,
+ login.id,
issued_at,
)
.fetch_one(&mut *self.0)