Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4dcd091cc | ||
|
|
86ad72b426 | ||
|
|
044d82d566 |
@@ -1,3 +1,5 @@
|
||||
Rocket.toml
|
||||
target
|
||||
.data
|
||||
|
||||
.vercel
|
||||
|
||||
@@ -138,12 +138,15 @@ pub async fn req(
|
||||
}
|
||||
|
||||
// 2. Validate changes
|
||||
let mut unknown_channels = HashSet::new();
|
||||
if let Some(system_messages) = &partial.system_messages {
|
||||
unknown_channels = system_messages.clone().into_channel_ids();
|
||||
for id in system_messages.clone().into_channel_ids() {
|
||||
if !server.channels.contains(&id) {
|
||||
return Err(Error::NotFound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(categories) = &partial.categories {
|
||||
if let Some(categories) = &mut partial.categories {
|
||||
let mut channel_ids = HashSet::new();
|
||||
for category in categories {
|
||||
for channel in &category.channels {
|
||||
@@ -153,13 +156,11 @@ pub async fn req(
|
||||
|
||||
channel_ids.insert(channel.to_string());
|
||||
}
|
||||
|
||||
category
|
||||
.channels
|
||||
.retain(|item| server.channels.contains(item));
|
||||
}
|
||||
|
||||
unknown_channels.extend(channel_ids);
|
||||
}
|
||||
|
||||
if !db.check_channels_exist(&unknown_channels).await? {
|
||||
return Err(Error::NotFound);
|
||||
}
|
||||
|
||||
// 3. Apply new icon
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -86,10 +86,8 @@ pub struct Masquerade {
|
||||
/// Replace the display role colour shown on this message
|
||||
///
|
||||
/// Must have `ManageRole` permission to use
|
||||
///
|
||||
/// This can be any valid CSS colour
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[validate(length(min = 1, max = 32))]
|
||||
#[validate(length(min = 1, max = 128), regex = "RE_COLOUR")]
|
||||
pub colour: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,15 @@ pub struct Relationship {
|
||||
/// Presence status
|
||||
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, PartialEq)]
|
||||
pub enum Presence {
|
||||
/// User is online
|
||||
Online,
|
||||
/// User is not currently available
|
||||
Idle,
|
||||
/// User is focusing / will only receive mentions
|
||||
Focus,
|
||||
/// User is busy / will not receive any notifications
|
||||
Busy,
|
||||
/// User appears to be offline
|
||||
Invisible,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::models::channel::{Channel, FieldsChannel, PartialChannel};
|
||||
use crate::{OverrideField, Result};
|
||||
|
||||
@@ -55,7 +53,4 @@ pub trait AbstractChannel: Sync + Send {
|
||||
role: &str,
|
||||
permissions: OverrideField,
|
||||
) -> Result<()>;
|
||||
|
||||
/// Validate existence of channels
|
||||
async fn check_channels_exist(&self, channels: &HashSet<String>) -> Result<bool>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user