chore(monorepo): delta, january, quark

This commit is contained in:
Paul Makles
2022-06-02 00:04:22 +01:00
parent 5d8432e267
commit 2ce610e1e7
232 changed files with 18094 additions and 554 deletions

View File

@@ -0,0 +1,46 @@
use crate::models::bot::{Bot, FieldsBot, PartialBot};
use crate::{AbstractBot, Result};
use super::super::DummyDb;
#[async_trait]
impl AbstractBot for DummyDb {
async fn fetch_bot(&self, id: &str) -> Result<Bot> {
Ok(Bot {
id: id.into(),
owner: "user".into(),
token: "token".into(),
public: true,
analytics: true,
discoverable: true,
..Default::default()
})
}
async fn fetch_bot_by_token(&self, _token: &str) -> Result<Bot> {
self.fetch_bot("bot").await
}
async fn insert_bot(&self, bot: &Bot) -> Result<()> {
info!("Insert {bot:?}");
Ok(())
}
async fn update_bot(&self, id: &str, bot: &PartialBot, remove: Vec<FieldsBot>) -> Result<()> {
info!("Update {id} with {bot:?} and remove {remove:?}");
Ok(())
}
async fn delete_bot(&self, id: &str) -> Result<()> {
info!("Delete {id}");
Ok(())
}
async fn fetch_bots_by_user(&self, user_id: &str) -> Result<Vec<Bot>> {
Ok(vec![self.fetch_bot(user_id).await.unwrap()])
}
async fn get_number_of_bots_by_user(&self, _user_id: &str) -> Result<usize> {
Ok(1)
}
}

View File

@@ -0,0 +1,78 @@
use crate::models::user::{FieldsUser, PartialUser, RelationshipStatus, User};
use crate::{AbstractUser, Result};
use super::super::DummyDb;
#[async_trait]
impl AbstractUser for DummyDb {
async fn fetch_user(&self, id: &str) -> Result<User> {
Ok(User {
id: id.into(),
username: "username".into(),
..Default::default()
})
}
async fn fetch_user_by_username(&self, username: &str) -> Result<User> {
self.fetch_user(username).await
}
async fn fetch_user_by_token(&self, token: &str) -> Result<User> {
self.fetch_user(token).await
}
async fn insert_user(&self, user: &User) -> Result<()> {
info!("Insert {:?}", user);
Ok(())
}
async fn update_user(
&self,
id: &str,
user: &PartialUser,
remove: Vec<FieldsUser>,
) -> Result<()> {
info!("Update {id} with {user:?} and remove {remove:?}");
Ok(())
}
async fn delete_user(&self, id: &str) -> Result<()> {
info!("Delete {id}");
Ok(())
}
async fn fetch_users<'a>(&self, _id: &'a [String]) -> Result<Vec<User>> {
Ok(vec![self.fetch_user("id").await.unwrap()])
}
async fn is_username_taken(&self, _username: &str) -> Result<bool> {
Ok(false)
}
async fn fetch_mutual_user_ids(&self, _user_a: &str, _user_b: &str) -> Result<Vec<String>> {
Ok(vec!["a".into()])
}
async fn fetch_mutual_channel_ids(&self, _user_a: &str, _user_b: &str) -> Result<Vec<String>> {
Ok(vec!["b".into()])
}
async fn fetch_mutual_server_ids(&self, _user_a: &str, _user_b: &str) -> Result<Vec<String>> {
Ok(vec!["c".into()])
}
async fn set_relationship(
&self,
user_id: &str,
target_id: &str,
relationship: &RelationshipStatus,
) -> Result<()> {
info!("Set relationship from {user_id} to {target_id} as {relationship:?}");
Ok(())
}
async fn pull_relationship(&self, user_id: &str, target_id: &str) -> Result<()> {
info!("Removing relationship from {user_id} to {target_id}");
Ok(())
}
}

View File

@@ -0,0 +1,25 @@
use crate::models::UserSettings;
use crate::{AbstractUserSettings, Result};
use super::super::DummyDb;
#[async_trait]
impl AbstractUserSettings for DummyDb {
async fn fetch_user_settings(
&'_ self,
_id: &str,
_filter: &'_ [String],
) -> Result<UserSettings> {
Ok(std::collections::HashMap::new())
}
async fn set_user_settings(&self, id: &str, settings: &UserSettings) -> Result<()> {
info!("Set {id} to {settings:?}");
Ok(())
}
async fn delete_user_settings(&self, id: &str) -> Result<()> {
info!("Delete {id}");
Ok(())
}
}