chore: lints
This commit is contained in:
parent
9236451628
commit
f56ca02d39
4 changed files with 6 additions and 20 deletions
|
@ -406,7 +406,7 @@ impl Database {
|
||||||
|
|
||||||
async fn create_event_type(&self) -> ServiceResult<()> {
|
async fn create_event_type(&self) -> ServiceResult<()> {
|
||||||
for e in &*EVENTS {
|
for e in &*EVENTS {
|
||||||
if !self.event_type_exists(&e).await? {
|
if !self.event_type_exists(e).await? {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO librepages_deploy_event_type
|
"INSERT INTO librepages_deploy_event_type
|
||||||
(name) VALUES ($1) ON CONFLICT (name) DO NOTHING;",
|
(name) VALUES ($1) ON CONFLICT (name) DO NOTHING;",
|
||||||
|
@ -823,7 +823,7 @@ mod tests {
|
||||||
// check if events are created
|
// check if events are created
|
||||||
for e in &*EVENTS {
|
for e in &*EVENTS {
|
||||||
println!("Testing event type exists {}", e.name);
|
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 {
|
let p = super::Register {
|
||||||
|
|
|
@ -22,15 +22,12 @@ use serde::{Deserialize, Serialize};
|
||||||
use tera::Context;
|
use tera::Context;
|
||||||
|
|
||||||
use super::get_auth_middleware;
|
use super::get_auth_middleware;
|
||||||
use crate::ctx::api::v1::auth::Login as LoginPayload;
|
|
||||||
use crate::db::Site;
|
use crate::db::Site;
|
||||||
use crate::errors::ServiceResult;
|
use crate::errors::ServiceResult;
|
||||||
use crate::pages::errors::*;
|
use crate::pages::errors::*;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::AppCtx;
|
use crate::AppCtx;
|
||||||
|
|
||||||
use crate::pages::errors::*;
|
|
||||||
|
|
||||||
use super::TemplateSiteEvent;
|
use super::TemplateSiteEvent;
|
||||||
|
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
|
@ -77,12 +74,7 @@ async fn get_site_data(ctx: &AppCtx, id: &Identity) -> ServiceResult<Vec<Templat
|
||||||
for site in db_sites {
|
for site in db_sites {
|
||||||
// TODO: impl method on DB to get latest "update" event
|
// TODO: impl method on DB to get latest "update" event
|
||||||
let mut events = ctx.db.list_all_site_events(&site.hostname).await?;
|
let mut events = ctx.db.list_all_site_events(&site.hostname).await?;
|
||||||
let last_update = if let Some(event) = events.pop() {
|
let last_update = events.pop().map(|event| event.into());
|
||||||
Some(event.into())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
sites.push(TemplateSite { site, last_update });
|
sites.push(TemplateSite { site, last_update });
|
||||||
}
|
}
|
||||||
Ok(sites)
|
Ok(sites)
|
||||||
|
@ -105,8 +97,6 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use actix_web::http::StatusCode;
|
use actix_web::http::StatusCode;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
use std::cell::RefCell;
|
|
||||||
|
|
||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::http::header;
|
use actix_web::http::header;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
@ -24,10 +22,8 @@ use rust_embed::RustEmbed;
|
||||||
use serde::*;
|
use serde::*;
|
||||||
use tera::*;
|
use tera::*;
|
||||||
|
|
||||||
use crate::pages::errors::*;
|
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::static_assets::ASSETS;
|
use crate::static_assets::ASSETS;
|
||||||
use crate::AppCtx;
|
|
||||||
use crate::{GIT_COMMIT_HASH, VERSION};
|
use crate::{GIT_COMMIT_HASH, VERSION};
|
||||||
|
|
||||||
pub mod auth;
|
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() {
|
let location = if id.identity().is_some() {
|
||||||
PAGES.home
|
PAGES.home
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,7 +15,7 @@ use actix_identity::Identity;
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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::errors::*;
|
||||||
use crate::pages;
|
use crate::pages;
|
||||||
|
@ -48,7 +48,7 @@ async fn index(req: HttpRequest, ctx: AppCtx, id: Identity) -> ServiceResult<imp
|
||||||
// serve meta page
|
// serve meta page
|
||||||
if host == ctx.settings.server.domain || host == "localhost" {
|
if host == ctx.settings.server.domain || host == "localhost" {
|
||||||
tracing::debug!("Into home");
|
tracing::debug!("Into home");
|
||||||
return Ok(pages::home(ctx.clone(), &id).await);
|
return Ok(pages::home(&id).await);
|
||||||
}
|
}
|
||||||
|
|
||||||
// serve default hostname content
|
// serve default hostname content
|
||||||
|
|
Loading…
Reference in a new issue