mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
refactor: clean up hints
This commit is contained in:
@@ -111,6 +111,7 @@ auto_derived!(
|
||||
|
||||
impl User {
|
||||
/// Check whether a username is already in use by another user
|
||||
#[allow(dead_code)]
|
||||
async fn is_username_taken(db: &Database, username: &str) -> Result<bool> {
|
||||
match db.fetch_user_by_username(username).await {
|
||||
Ok(_) => Ok(true),
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::{Database, User};
|
||||
|
||||
/// Permissions calculator
|
||||
pub struct PermissionCalculator<'a> {
|
||||
#[allow(dead_code)]
|
||||
database: &'a Database,
|
||||
|
||||
perspective: &'a User,
|
||||
|
||||
@@ -57,7 +57,7 @@ pub async fn report_content(db: &Db, user: User, data: Json<DataReportContent>)
|
||||
return Err(Error::CannotReportYourself);
|
||||
}
|
||||
|
||||
let (snapshot, files) = SnapshotContent::generate_from_server(db, server)?;
|
||||
let (snapshot, files) = SnapshotContent::generate_from_server(server)?;
|
||||
(vec![snapshot], files)
|
||||
}
|
||||
ReportedContent::User { id, message_id, .. } => {
|
||||
@@ -75,7 +75,7 @@ pub async fn report_content(db: &Db, user: User, data: Json<DataReportContent>)
|
||||
None
|
||||
};
|
||||
|
||||
let (snapshot, files) = SnapshotContent::generate_from_user(db, reported_user)?;
|
||||
let (snapshot, files) = SnapshotContent::generate_from_user(reported_user)?;
|
||||
|
||||
if let Some(message) = message {
|
||||
let (message_snapshot, message_files) =
|
||||
|
||||
@@ -61,10 +61,7 @@ impl SnapshotContent {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn generate_from_server(
|
||||
db: &Database,
|
||||
server: Server,
|
||||
) -> Result<(SnapshotContent, Vec<String>)> {
|
||||
pub fn generate_from_server(server: Server) -> Result<(SnapshotContent, Vec<String>)> {
|
||||
// Collect server's icon and banner
|
||||
let files = [&server.icon, &server.banner]
|
||||
.iter()
|
||||
@@ -74,7 +71,7 @@ impl SnapshotContent {
|
||||
Ok((SnapshotContent::Server(server), files))
|
||||
}
|
||||
|
||||
pub fn generate_from_user(db: &Database, user: User) -> Result<(SnapshotContent, Vec<String>)> {
|
||||
pub fn generate_from_user(user: User) -> Result<(SnapshotContent, Vec<String>)> {
|
||||
// Collect user's avatar and profile background
|
||||
let files = [
|
||||
user.avatar.as_ref(),
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
use crate::Database;
|
||||
|
||||
use deadqueue::limited::Queue;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
|
||||
use super::DelayedTask;
|
||||
|
||||
@@ -95,7 +95,7 @@ pub async fn worker(db: Database) {
|
||||
}) = Q.try_pop()
|
||||
{
|
||||
let key = (user, channel);
|
||||
if let Some(mut task) = tasks.get_mut(&key) {
|
||||
if let Some(task) = tasks.get_mut(&key) {
|
||||
task.delay();
|
||||
|
||||
match &mut event {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
use crate::{models::channel::PartialChannel, Database};
|
||||
|
||||
use deadqueue::limited::Queue;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
|
||||
use super::DelayedTask;
|
||||
|
||||
@@ -73,7 +73,7 @@ pub async fn worker(db: Database) {
|
||||
|
||||
// Queue incoming tasks.
|
||||
while let Some(Data { channel, id, is_dm }) = Q.try_pop() {
|
||||
if let Some(mut task) = tasks.get_mut(&channel) {
|
||||
if let Some(task) = tasks.get_mut(&channel) {
|
||||
task.data.id = id;
|
||||
task.delay();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user