chore: Write tests for pinning

This commit is contained in:
Zomatree
2024-07-21 22:22:46 +01:00
parent c50435d499
commit 87a9fb79f2
6 changed files with 186 additions and 6 deletions

View File

@@ -81,7 +81,7 @@ impl Member {
server: &Server,
user: &User,
channels: Option<Vec<Channel>>,
) -> Result<Vec<Channel>> {
) -> Result<(Member, Vec<Channel>)> {
if db.fetch_ban(&server.id, &user.id).await.is_ok() {
return Err(create_error!(Banned));
}
@@ -155,7 +155,7 @@ impl Member {
.ok();
}
Ok(channels)
Ok((member, channels))
}
/// Update member data

View File

@@ -18,6 +18,10 @@ static TOKEN_CACHE: Lazy<Mutex<lru::LruCache<String, ()>>> =
Lazy::new(|| Mutex::new(lru::LruCache::new(NonZeroUsize::new(1000).unwrap())));
impl IdempotencyKey {
pub fn unchecked_from_string(key: String) -> Self {
Self { key }
}
// Backwards compatibility.
// Issue #109
pub async fn consume_nonce(&mut self, v: Option<String>) -> Result<()> {