chore: lints

This commit is contained in:
Aravinth Manivannan 2022-12-03 16:12:19 +05:30
parent 9236451628
commit f56ca02d39
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
4 changed files with 6 additions and 20 deletions

View File

@ -406,7 +406,7 @@ impl Database {
async fn create_event_type(&self) -> ServiceResult<()> {
for e in &*EVENTS {
if !self.event_type_exists(&e).await? {
if !self.event_type_exists(e).await? {
sqlx::query!(
"INSERT INTO librepages_deploy_event_type
(name) VALUES ($1) ON CONFLICT (name) DO NOTHING;",
@ -823,7 +823,7 @@ mod tests {
// check if events are created
for e in &*EVENTS {
println!("Testing event type exists {}", e.name);
assert!(db.event_type_exists(&e).await.unwrap());
assert!(db.event_type_exists(e).await.unwrap());
}
let p = super::Register {

View File

@ -22,15 +22,12 @@ use serde::{Deserialize, Serialize};
use tera::Context;
use super::get_auth_middleware;
use crate::ctx::api::v1::auth::Login as LoginPayload;
use crate::db::Site;
use crate::errors::ServiceResult;
use crate::pages::errors::*;
use crate::settings::Settings;
use crate::AppCtx;
use crate::pages::errors::*;
use super::TemplateSiteEvent;
pub use super::*;
@ -77,12 +74,7 @@ async fn get_site_data(ctx: &AppCtx, id: &Identity) -> ServiceResult<Vec<Templat
for site in db_sites {
// TODO: impl method on DB to get latest "update" event
let mut events = ctx.db.list_all_site_events(&site.hostname).await?;
let last_update = if let Some(event) = events.pop() {
Some(event.into())
} else {
None
};
let last_update = events.pop().map(|event| event.into());
sites.push(TemplateSite { site, last_update });
}
Ok(sites)
@ -105,8 +97,6 @@ pub fn services(cfg: &mut web::ServiceConfig) {
#[cfg(test)]
mod tests {
use super::*;
use actix_web::http::StatusCode;
use actix_web::test;

View File

@ -14,8 +14,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use std::cell::RefCell;
use actix_identity::Identity;
use actix_web::http::header;
use actix_web::*;
@ -24,10 +22,8 @@ use rust_embed::RustEmbed;
use serde::*;
use tera::*;
use crate::pages::errors::*;
use crate::settings::Settings;
use crate::static_assets::ASSETS;
use crate::AppCtx;
use crate::{GIT_COMMIT_HASH, VERSION};
pub mod auth;
@ -134,7 +130,7 @@ impl<'a> Footer<'a> {
}
}
pub async fn home(ctx: AppCtx, id: &Identity) -> HttpResponse {
pub async fn home(id: &Identity) -> HttpResponse {
let location = if id.identity().is_some() {
PAGES.home
} else {

View File

@ -15,7 +15,7 @@ use actix_identity::Identity;
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use actix_web::{http::header::ContentType, web, HttpRequest, HttpResponse, Responder};
use actix_web::{web, HttpRequest, HttpResponse, Responder};
use crate::errors::*;
use crate::pages;
@ -48,7 +48,7 @@ async fn index(req: HttpRequest, ctx: AppCtx, id: Identity) -> ServiceResult<imp
// serve meta page
if host == ctx.settings.server.domain || host == "localhost" {
tracing::debug!("Into home");
return Ok(pages::home(ctx.clone(), &id).await);
return Ok(pages::home(&id).await);
}
// serve default hostname content