add announce command, fix multi-occurence command matching

This commit is contained in:
2021-08-22 11:51:08 +02:00
parent 99d9b83c68
commit 84ff6a8ae2
9 changed files with 403 additions and 237 deletions
+5 -4
View File
@@ -1,9 +1,10 @@
use std::collections::{HashMap, HashSet};
use crate::store;
use crate::store::GroupError;
use elefren::AppData;
use crate::error::GroupError;
use crate::store;
/// This is the inner data struct holding the config
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub(crate) struct Config {
@@ -239,8 +240,8 @@ fn acct_to_server(acct: &str) -> &str {
#[cfg(test)]
mod tests {
use crate::store::{GroupError};
use crate::store::data::{GroupConfig, acct_to_server};
use crate::error::GroupError;
use crate::store::data::{acct_to_server, GroupConfig};
#[test]
fn test_acct_to_server() {
+1 -31
View File
@@ -10,6 +10,7 @@ use tokio::sync::RwLock;
use data::{Config, GroupConfig};
use crate::error::GroupError;
use crate::group_handle::GroupHandle;
pub(crate) mod data;
@@ -168,37 +169,6 @@ impl ConfigStore {
}
}
#[derive(Debug, Error)]
pub enum GroupError {
#[error("User is admin")]
UserIsAdmin,
#[error("User is banned")]
UserIsBanned,
#[error("Server could not be banned because there are admin users on it")]
AdminsOnServer,
#[error("Group config is missing in the config store")]
GroupNotExist,
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
Serializer(#[from] serde_json::Error),
#[error(transparent)]
Elefren(#[from] elefren::Error),
}
// this is for tests
impl PartialEq for GroupError {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::UserIsAdmin, Self::UserIsAdmin) => true,
(Self::UserIsBanned, Self::UserIsBanned) => true,
(Self::AdminsOnServer, Self::AdminsOnServer) => true,
(Self::GroupNotExist, Self::GroupNotExist) => true,
_ => false,
}
}
}
fn make_scopes() -> Scopes {
Scopes::read(scopes::Read::Accounts)
| Scopes::read(scopes::Read::Notifications)