fix: strip unknown channels from categories (fixes #201)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::models::channel::{Channel, FieldsChannel, PartialChannel};
|
||||
use crate::{AbstractAttachment, AbstractChannel, Error, OverrideField, Result};
|
||||
|
||||
@@ -83,8 +81,4 @@ impl AbstractChannel for DummyDb {
|
||||
info!("Updating permissions for role {role} in {channel} with {permissions:?}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn check_channels_exist(&self, _channels: &HashSet<String>) -> Result<bool> {
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use bson::{Bson, Document};
|
||||
|
||||
use crate::models::channel::{Channel, FieldsChannel, PartialChannel};
|
||||
@@ -291,25 +289,6 @@ impl AbstractChannel for MongoDb {
|
||||
with: "channel",
|
||||
})
|
||||
}
|
||||
|
||||
async fn check_channels_exist(&self, channels: &HashSet<String>) -> Result<bool> {
|
||||
let count = channels.len() as u64;
|
||||
self.col::<Document>(COL)
|
||||
.count_documents(
|
||||
doc! {
|
||||
"_id": {
|
||||
"$in": channels.iter().cloned().collect::<Vec<String>>()
|
||||
}
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.map(|x| x == count)
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "count_documents",
|
||||
with: "channel",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoDocumentPath for FieldsChannel {
|
||||
|
||||
Reference in New Issue
Block a user