fix: use correct key name for auth bots collection
This commit is contained in:
@@ -17,17 +17,25 @@ impl AbstractAuthorizedBots for MongoDb {
|
|||||||
|
|
||||||
/// Fetch an authorized bot by its id
|
/// Fetch an authorized bot by its id
|
||||||
async fn fetch_authorized_bot(&self, id: &AuthorizedBotId) -> Result<AuthorizedBot> {
|
async fn fetch_authorized_bot(&self, id: &AuthorizedBotId) -> Result<AuthorizedBot> {
|
||||||
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
|
/// Fetch a users authorized bot by its id
|
||||||
async fn fetch_users_authorized_bots(&self, user_id: &str) -> Result<Vec<AuthorizedBot>> {
|
async fn fetch_users_authorized_bots(&self, user_id: &str) -> Result<Vec<AuthorizedBot>> {
|
||||||
query!(self, find, COL, doc! { "id.user": &user_id })
|
query!(self, find, COL, doc! { "_id.user": &user_id })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes an authorized bot
|
/// Deletes an authorized bot
|
||||||
async fn delete_authorized_bot(&self, id: &AuthorizedBotId) -> Result<()> {
|
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
|
/// Deauthorizes an authorized bot
|
||||||
@@ -35,8 +43,8 @@ impl AbstractAuthorizedBots for MongoDb {
|
|||||||
self.col::<AuthorizedBot>(COL)
|
self.col::<AuthorizedBot>(COL)
|
||||||
.find_one_and_update(
|
.find_one_and_update(
|
||||||
doc! {
|
doc! {
|
||||||
"id.user": &id.user,
|
"_id.user": &id.user,
|
||||||
"id.bot": &id.bot
|
"_id.bot": &id.bot
|
||||||
},
|
},
|
||||||
doc! {
|
doc! {
|
||||||
"$set": {
|
"$set": {
|
||||||
@@ -60,4 +68,4 @@ impl AbstractAuthorizedBots for MongoDb {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user