From 83c15404a5437706f74b4fccc54198da3e076a54 Mon Sep 17 00:00:00 2001 From: Zomatree Date: Tue, 22 Jul 2025 00:07:32 +0100 Subject: [PATCH] fix: use correct key name for auth bots collection --- .../src/models/authorized_bots/ops/mongodb.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/core/database/src/models/authorized_bots/ops/mongodb.rs b/crates/core/database/src/models/authorized_bots/ops/mongodb.rs index cb868c7e..7667fccc 100644 --- a/crates/core/database/src/models/authorized_bots/ops/mongodb.rs +++ b/crates/core/database/src/models/authorized_bots/ops/mongodb.rs @@ -17,17 +17,25 @@ impl AbstractAuthorizedBots for MongoDb { /// Fetch an authorized bot by its id async fn fetch_authorized_bot(&self, id: &AuthorizedBotId) -> Result { - query!(self, find_one, COL, doc! { "id.user": &id.user, "id.bot": &id.bot })?.ok_or_else(|| create_error!(NotFound)) + query!( + self, + find_one, + COL, + doc! { + "_id.user": &id.user, + "_id.bot": &id.bot + } + )?.ok_or_else(|| create_error!(NotFound)) } /// Fetch a users authorized bot by its id async fn fetch_users_authorized_bots(&self, user_id: &str) -> Result> { - query!(self, find, COL, doc! { "id.user": &user_id }) + query!(self, find, COL, doc! { "_id.user": &user_id }) } /// Deletes an authorized bot async fn delete_authorized_bot(&self, id: &AuthorizedBotId) -> Result<()> { - query!(self, delete_one, COL, doc! { "id.user": &id.user, "id.bot": &id.bot }).map(|_| ()) + query!(self, delete_one, COL, doc! { "_id.user": &id.user, "_id.bot": &id.bot }).map(|_| ()) } /// Deauthorizes an authorized bot @@ -35,8 +43,8 @@ impl AbstractAuthorizedBots for MongoDb { self.col::(COL) .find_one_and_update( doc! { - "id.user": &id.user, - "id.bot": &id.bot + "_id.user": &id.user, + "_id.bot": &id.bot }, doc! { "$set": { @@ -60,4 +68,4 @@ impl AbstractAuthorizedBots for MongoDb { } ) } -} \ No newline at end of file +}