Rust 2018! (#726)

This commit is contained in:
Ana Gelez 2020-01-21 07:02:03 +01:00 committed by Igor Galić
parent 3663bffe5c
commit 5f8d6b8e0e
115 changed files with 447 additions and 582 deletions

View file

@ -3,6 +3,7 @@ authors = ["Plume contributors"]
name = "plume" name = "plume"
version = "0.4.0" version = "0.4.0"
repository = "https://github.com/Plume-org/Plume" repository = "https://github.com/Plume-org/Plume"
edition = "2018"
[dependencies] [dependencies]
activitypub = "0.1.3" activitypub = "0.1.3"

View file

@ -1,5 +1,5 @@
extern crate rsass; use rsass;
extern crate ructe;
use ructe::Ructe; use ructe::Ructe;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::{ffi::OsStr, fs::*, io::Write, path::*}; use std::{ffi::OsStr, fs::*, io::Write, path::*};

View file

@ -2,6 +2,7 @@
name = "plume-api" name = "plume-api"
version = "0.4.0" version = "0.4.0"
authors = ["Plume contributors"] authors = ["Plume contributors"]
edition = "2018"
[dependencies] [dependencies]
serde = "1.0" serde = "1.0"

View file

@ -1,4 +1,3 @@
extern crate serde;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;

View file

@ -2,6 +2,7 @@
name = "plume-cli" name = "plume-cli"
version = "0.4.0" version = "0.4.0"
authors = ["Plume contributors"] authors = ["Plume contributors"]
edition = "2018"
[[bin]] [[bin]]
name = "plm" name = "plm"

View file

@ -1,8 +1,4 @@
extern crate clap; use dotenv;
extern crate diesel;
extern crate dotenv;
extern crate plume_models;
extern crate rpassword;
use clap::App; use clap::App;
use diesel::Connection; use diesel::Connection;

View file

@ -2,6 +2,7 @@
name = "plume-common" name = "plume-common"
version = "0.4.0" version = "0.4.0"
authors = ["Plume contributors"] authors = ["Plume contributors"]
edition = "2018"
[dependencies] [dependencies]
activitypub = "0.1.1" activitypub = "0.1.1"

View file

@ -64,7 +64,7 @@ impl<T> ActivityStream<T> {
} }
impl<'r, O: Object> Responder<'r> for ActivityStream<O> { impl<'r, O: Object> Responder<'r> for ActivityStream<O> {
fn respond_to(self, request: &Request) -> Result<Response<'r>, Status> { fn respond_to(self, request: &Request<'_>) -> Result<Response<'r>, Status> {
let mut json = serde_json::to_value(&self.0).map_err(|_| Status::InternalServerError)?; let mut json = serde_json::to_value(&self.0).map_err(|_| Status::InternalServerError)?;
json["@context"] = context(); json["@context"] = context();
serde_json::to_string(&json).respond_to(request).map(|r| { serde_json::to_string(&json).respond_to(request).map(|r| {

View file

@ -5,8 +5,8 @@ use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE, DATE, USER_A
use std::ops::Deref; use std::ops::Deref;
use std::time::SystemTime; use std::time::SystemTime;
use activity_pub::sign::Signer; use crate::activity_pub::sign::Signer;
use activity_pub::{ap_accept_header, AP_CONTENT_TYPE}; use crate::activity_pub::{ap_accept_header, AP_CONTENT_TYPE};
const PLUME_USER_AGENT: &str = concat!("Plume/", env!("CARGO_PKG_VERSION")); const PLUME_USER_AGENT: &str = concat!("Plume/", env!("CARGO_PKG_VERSION"));

View file

@ -131,7 +131,7 @@ impl SignatureValidity {
pub fn verify_http_headers<S: Signer + ::std::fmt::Debug>( pub fn verify_http_headers<S: Signer + ::std::fmt::Debug>(
sender: &S, sender: &S,
all_headers: &HeaderMap, all_headers: &HeaderMap<'_>,
data: &request::Digest, data: &request::Digest,
) -> SignatureValidity { ) -> SignatureValidity {
let sig_header = all_headers.get_one("Signature"); let sig_header = all_headers.get_one("Signature");

View file

@ -1,27 +1,16 @@
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
extern crate activitypub;
#[macro_use] #[macro_use]
extern crate activitystreams_derive; extern crate activitystreams_derive;
extern crate activitystreams_traits; use activitystreams_traits;
extern crate array_tool;
extern crate base64; use serde;
extern crate chrono;
extern crate heck;
extern crate hex;
extern crate openssl;
extern crate pulldown_cmark;
extern crate reqwest;
extern crate rocket;
extern crate serde;
#[macro_use] #[macro_use]
extern crate shrinkwraprs; extern crate shrinkwraprs;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[macro_use] #[macro_use]
extern crate serde_json; extern crate serde_json;
extern crate syntect;
extern crate tokio;
pub mod activity_pub; pub mod activity_pub;
pub mod utils; pub mod utils;

View file

@ -48,7 +48,7 @@ enum State {
Ready, Ready,
} }
fn to_inline(tag: Tag) -> Tag { fn to_inline(tag: Tag<'_>) -> Tag<'_> {
match tag { match tag {
Tag::Header(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => { Tag::Header(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
Tag::Paragraph Tag::Paragraph
@ -214,7 +214,7 @@ pub fn md_to_html<'a>(
}; };
let parser = Parser::new_ext(md, Options::all()); let parser = Parser::new_ext(md, Options::all());
let (parser, mentions, hashtags): (Vec<Event>, Vec<String>, Vec<String>) = parser let (parser, mentions, hashtags): (Vec<Event<'_>>, Vec<String>, Vec<String>) = parser
// Flatten text because pulldown_cmark break #hashtag in two individual text elements // Flatten text because pulldown_cmark break #hashtag in two individual text elements
.scan(None, flatten_text) .scan(None, flatten_text)
.flatten() .flatten()

View file

@ -2,6 +2,7 @@
name = "plume-front" name = "plume-front"
version = "0.4.0" version = "0.4.0"
authors = ["Plume contributors"] authors = ["Plume contributors"]
edition = "2018"
[dependencies] [dependencies]
stdweb = "=0.4.18" stdweb = "=0.4.18"

View file

@ -1,3 +1,4 @@
use crate::CATALOG;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json; use serde_json;
use std::sync::Mutex; use std::sync::Mutex;
@ -5,7 +6,6 @@ use stdweb::{
unstable::{TryFrom, TryInto}, unstable::{TryFrom, TryInto},
web::{event::*, html_element::*, *}, web::{event::*, html_element::*, *},
}; };
use CATALOG;
macro_rules! mv { macro_rules! mv {
( $( $var:ident ),* => $exp:expr ) => { ( $( $var:ident ),* => $exp:expr ) => {

View file

@ -1,15 +1,12 @@
#![recursion_limit = "128"] #![recursion_limit = "128"]
#![feature(decl_macro, proc_macro_hygiene, try_trait)] #![feature(decl_macro, proc_macro_hygiene, try_trait)]
extern crate gettext;
#[macro_use] #[macro_use]
extern crate gettext_macros; extern crate gettext_macros;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate stdweb; extern crate stdweb;
extern crate serde;
extern crate serde_json;
use stdweb::web::{event::*, *}; use stdweb::web::{event::*, *};
init_i18n!( init_i18n!(

View file

@ -1,8 +1,7 @@
#![recursion_limit = "128"] #![recursion_limit = "128"]
extern crate proc_macro;
#[macro_use] #[macro_use]
extern crate quote; extern crate quote;
extern crate syn;
use proc_macro::TokenStream; use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2; use proc_macro2::TokenStream as TokenStream2;

View file

@ -2,6 +2,7 @@
name = "plume-models" name = "plume-models"
version = "0.4.0" version = "0.4.0"
authors = ["Plume contributors"] authors = ["Plume contributors"]
edition = "2018"
[dependencies] [dependencies]
activitypub = "0.1.1" activitypub = "0.1.1"

View file

@ -1,11 +1,10 @@
use crate::users::User;
use rocket::{ use rocket::{
http::Status, http::Status,
request::{self, FromRequest, Request}, request::{self, FromRequest, Request},
Outcome, Outcome,
}; };
use users::User;
/// Wrapper around User to use as a request guard on pages reserved to admins. /// Wrapper around User to use as a request guard on pages reserved to admins.
pub struct Admin(pub User); pub struct Admin(pub User);

View file

@ -1,3 +1,4 @@
use crate::{db_conn::DbConn, schema::api_tokens, Error, Result};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use rocket::{ use rocket::{
@ -6,10 +7,6 @@ use rocket::{
Outcome, Outcome,
}; };
use db_conn::DbConn;
use schema::api_tokens;
use {Error, Result};
#[derive(Clone, Queryable)] #[derive(Clone, Queryable)]
pub struct ApiToken { pub struct ApiToken {
pub id: i32, pub id: i32,

View file

@ -1,9 +1,7 @@
use crate::{schema::apps, Error, Result};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use schema::apps;
use {Error, Result};
#[derive(Clone, Queryable, Serialize)] #[derive(Clone, Queryable, Serialize)]
pub struct App { pub struct App {
pub id: i32, pub id: i32,

View file

@ -1,9 +1,7 @@
use crate::{schema::email_blocklist, Connection, Error, Result};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, TextExpressionMethods}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, TextExpressionMethods};
use glob::Pattern; use glob::Pattern;
use schema::email_blocklist;
use {Connection, Error, Result};
#[derive(Clone, Queryable, Identifiable)] #[derive(Clone, Queryable, Identifiable)]
#[table_name = "email_blocklist"] #[table_name = "email_blocklist"]
pub struct BlocklistedEmail { pub struct BlocklistedEmail {
@ -89,10 +87,9 @@ impl BlocklistedEmail {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::{instance::tests as instance_tests, tests::rockets, Connection as Conn};
use diesel::Connection; use diesel::Connection;
use instance::tests as instance_tests;
use tests::rockets;
use Connection as Conn;
pub(crate) fn fill_database(conn: &Conn) -> Vec<BlocklistedEmail> { pub(crate) fn fill_database(conn: &Conn) -> Vec<BlocklistedEmail> {
instance_tests::fill_database(conn); instance_tests::fill_database(conn);
let domainblock = let domainblock =

View file

@ -1,8 +1,6 @@
use crate::{schema::blog_authors, Error, Result};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use schema::blog_authors;
use {Error, Result};
#[derive(Clone, Queryable, Identifiable)] #[derive(Clone, Queryable, Identifiable)]
pub struct BlogAuthor { pub struct BlogAuthor {
pub id: i32, pub id: i32,

View file

@ -1,3 +1,7 @@
use crate::{
ap_url, instance::*, medias::Media, posts::Post, safe_string::SafeString, schema::blogs,
search::Searcher, users::User, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE,
};
use activitypub::{ use activitypub::{
actor::Group, actor::Group,
collection::{OrderedCollection, OrderedCollectionPage}, collection::{OrderedCollection, OrderedCollectionPage},
@ -12,22 +16,13 @@ use openssl::{
rsa::Rsa, rsa::Rsa,
sign::{Signer, Verifier}, sign::{Signer, Verifier},
}; };
use serde_json;
use url::Url;
use webfinger::*;
use instance::*;
use medias::Media;
use plume_common::activity_pub::{ use plume_common::activity_pub::{
inbox::{AsActor, FromId}, inbox::{AsActor, FromId},
sign, ActivityStream, ApSignature, Id, IntoId, PublicKey, Source, sign, ActivityStream, ApSignature, Id, IntoId, PublicKey, Source,
}; };
use posts::Post; use serde_json;
use safe_string::SafeString; use url::Url;
use schema::blogs; use webfinger::*;
use search::Searcher;
use users::User;
use {ap_url, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE};
pub type CustomGroup = CustomObject<ApSignature, Group>; pub type CustomGroup = CustomObject<ApSignature, Group>;
@ -106,8 +101,8 @@ impl Blog {
} }
pub fn list_authors(&self, conn: &Connection) -> Result<Vec<User>> { pub fn list_authors(&self, conn: &Connection) -> Result<Vec<User>> {
use schema::blog_authors; use crate::schema::blog_authors;
use schema::users; use crate::schema::users;
let authors_ids = blog_authors::table let authors_ids = blog_authors::table
.filter(blog_authors::blog_id.eq(self.id)) .filter(blog_authors::blog_id.eq(self.id))
.select(blog_authors::author_id); .select(blog_authors::author_id);
@ -118,7 +113,7 @@ impl Blog {
} }
pub fn count_authors(&self, conn: &Connection) -> Result<i64> { pub fn count_authors(&self, conn: &Connection) -> Result<i64> {
use schema::blog_authors; use crate::schema::blog_authors;
blog_authors::table blog_authors::table
.filter(blog_authors::blog_id.eq(self.id)) .filter(blog_authors::blog_id.eq(self.id))
.count() .count()
@ -127,7 +122,7 @@ impl Blog {
} }
pub fn find_for_author(conn: &Connection, author: &User) -> Result<Vec<Blog>> { pub fn find_for_author(conn: &Connection, author: &User) -> Result<Vec<Blog>> {
use schema::blog_authors; use crate::schema::blog_authors;
let author_ids = blog_authors::table let author_ids = blog_authors::table
.filter(blog_authors::author_id.eq(author.id)) .filter(blog_authors::author_id.eq(author.id))
.select(blog_authors::blog_id); .select(blog_authors::blog_id);
@ -501,14 +496,16 @@ impl NewBlog {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use blog_authors::*; use crate::{
blog_authors::*,
instance::tests as instance_tests,
medias::NewMedia,
search::tests::get_searcher,
tests::{db, rockets},
users::tests as usersTests,
Connection as Conn,
};
use diesel::Connection; use diesel::Connection;
use instance::tests as instance_tests;
use medias::NewMedia;
use search::tests::get_searcher;
use tests::{db, rockets};
use users::tests as usersTests;
use Connection as Conn;
pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Blog>) { pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Blog>) {
instance_tests::fill_database(conn); instance_tests::fill_database(conn);

View file

@ -1,10 +1,6 @@
use crate::{comments::Comment, schema::comment_seers, users::User, Connection, Error, Result};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use comments::Comment;
use schema::comment_seers;
use users::User;
use {Connection, Error, Result};
#[derive(Queryable, Clone)] #[derive(Queryable, Clone)]
pub struct CommentSeers { pub struct CommentSeers {
pub id: i32, pub id: i32,

View file

@ -1,3 +1,15 @@
use crate::{
comment_seers::{CommentSeers, NewCommentSeers},
instance::Instance,
medias::Media,
mentions::Mention,
notifications::*,
posts::Post,
safe_string::SafeString,
schema::comments,
users::User,
Connection, Error, PlumeRocket, Result,
};
use activitypub::{ use activitypub::{
activity::{Create, Delete}, activity::{Create, Delete},
link, link,
@ -5,25 +17,15 @@ use activitypub::{
}; };
use chrono::{self, NaiveDateTime}; use chrono::{self, NaiveDateTime};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use serde_json; use plume_common::{
activity_pub::{
use std::collections::HashSet;
use comment_seers::{CommentSeers, NewCommentSeers};
use instance::Instance;
use medias::Media;
use mentions::Mention;
use notifications::*;
use plume_common::activity_pub::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
},
utils,
}; };
use plume_common::utils; use serde_json;
use posts::Post; use std::collections::HashSet;
use safe_string::SafeString;
use schema::comments;
use users::User;
use {Connection, Error, PlumeRocket, Result};
#[derive(Queryable, Identifiable, Clone, AsChangeset)] #[derive(Queryable, Identifiable, Clone, AsChangeset)]
pub struct Comment { pub struct Comment {
@ -77,7 +79,7 @@ impl Comment {
} }
pub fn count_local(conn: &Connection) -> Result<i64> { pub fn count_local(conn: &Connection) -> Result<i64> {
use schema::users; use crate::schema::users;
let local_authors = users::table let local_authors = users::table
.filter(users::instance_id.eq(Instance::get_local()?.id)) .filter(users::instance_id.eq(Instance::get_local()?.id))
.select(users::id); .select(users::id);

View file

@ -1,3 +1,4 @@
use crate::Connection;
use diesel::r2d2::{ use diesel::r2d2::{
ConnectionManager, CustomizeConnection, Error as ConnError, Pool, PooledConnection, ConnectionManager, CustomizeConnection, Error as ConnError, Pool, PooledConnection,
}; };
@ -10,8 +11,6 @@ use rocket::{
}; };
use std::ops::Deref; use std::ops::Deref;
use Connection;
pub type DbPool = Pool<ConnectionManager<Connection>>; pub type DbPool = Pool<ConnectionManager<Connection>>;
// From rocket documentation // From rocket documentation
@ -26,7 +25,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for DbConn {
type Error = (); type Error = ();
fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> { fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
let pool = request.guard::<State<DbPool>>()?; let pool = request.guard::<State<'_, DbPool>>()?;
match pool.get() { match pool.get() {
Ok(conn) => Outcome::Success(DbConn(conn)), Ok(conn) => Outcome::Success(DbConn(conn)),
Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())), Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())),

View file

@ -1,16 +1,15 @@
use crate::{
ap_url, notifications::*, schema::follows, users::User, Connection, Error, PlumeRocket, Result,
CONFIG,
};
use activitypub::activity::{Accept, Follow as FollowAct, Undo}; use activitypub::activity::{Accept, Follow as FollowAct, Undo};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use notifications::*;
use plume_common::activity_pub::{ use plume_common::activity_pub::{
broadcast, broadcast,
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
sign::Signer, sign::Signer,
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
}; };
use schema::follows;
use users::User;
use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG};
#[derive(Clone, Queryable, Identifiable, Associations, AsChangeset)] #[derive(Clone, Queryable, Identifiable, Associations, AsChangeset)]
#[belongs_to(User, foreign_key = "following_id")] #[belongs_to(User, foreign_key = "following_id")]
@ -201,9 +200,8 @@ impl IntoId for Follow {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{tests::db, users::tests as user_tests};
use diesel::Connection; use diesel::Connection;
use tests::db;
use users::tests as user_tests;
#[test] #[test]
fn test_id() { fn test_id() {

View file

@ -1,14 +1,15 @@
use crate::{
ap_url,
medias::Media,
safe_string::SafeString,
schema::{instances, users},
users::{Role, User},
Connection, Error, Result,
};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use std::sync::RwLock;
use ap_url;
use medias::Media;
use plume_common::utils::md_to_html; use plume_common::utils::md_to_html;
use safe_string::SafeString; use std::sync::RwLock;
use schema::{instances, users};
use users::{Role, User};
use {Connection, Error, Result};
#[derive(Clone, Identifiable, Queryable)] #[derive(Clone, Identifiable, Queryable)]
pub struct Instance { pub struct Instance {
@ -242,9 +243,8 @@ impl Instance {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::{tests::db, Connection as Conn};
use diesel::Connection; use diesel::Connection;
use tests::db;
use Connection as Conn;
pub(crate) fn fill_database(conn: &Conn) -> Vec<(NewInstance, Instance)> { pub(crate) fn fill_database(conn: &Conn) -> Vec<(NewInstance, Instance)> {
let res = vec![ let res = vec![

View file

@ -2,41 +2,20 @@
#![feature(never_type)] #![feature(never_type)]
#![feature(proc_macro_hygiene)] #![feature(proc_macro_hygiene)]
extern crate activitypub;
extern crate ammonia;
extern crate askama_escape;
extern crate bcrypt;
extern crate chrono;
#[macro_use] #[macro_use]
extern crate diesel; extern crate diesel;
extern crate guid_create;
extern crate heck;
extern crate itertools;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
extern crate migrations_internals;
extern crate openssl;
extern crate plume_api;
extern crate plume_common;
#[macro_use] #[macro_use]
extern crate plume_macro; extern crate plume_macro;
extern crate reqwest;
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
extern crate rocket_i18n;
extern crate scheduled_thread_pool;
extern crate serde;
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;
#[macro_use] #[macro_use]
extern crate serde_json; extern crate serde_json;
#[macro_use] #[macro_use]
extern crate tantivy; extern crate tantivy;
extern crate glob;
extern crate url;
extern crate walkdir;
extern crate webfinger;
extern crate whatlang;
use plume_common::activity_pub::inbox::InboxError; use plume_common::activity_pub::inbox::InboxError;
@ -249,10 +228,10 @@ macro_rules! get {
/// Model::insert(connection, NewModelType::new()); /// Model::insert(connection, NewModelType::new());
/// ``` /// ```
macro_rules! insert { macro_rules! insert {
($table:ident, $from:ident) => { ($table:ident, $from:ty) => {
insert!($table, $from, |x, _conn| Ok(x)); insert!($table, $from, |x, _conn| Ok(x));
}; };
($table:ident, $from:ident, |$val:ident, $conn:ident | $( $after:tt )+) => { ($table:ident, $from:ty, |$val:ident, $conn:ident | $( $after:tt )+) => {
last!($table); last!($table);
#[allow(dead_code)] #[allow(dead_code)]
@ -302,16 +281,12 @@ pub fn ap_url(url: &str) -> String {
#[cfg(test)] #[cfg(test)]
#[macro_use] #[macro_use]
mod tests { mod tests {
use db_conn; use crate::{db_conn, migrations::IMPORTED_MIGRATIONS, search, Connection as Conn, CONFIG};
use diesel::r2d2::ConnectionManager; use diesel::r2d2::ConnectionManager;
use migrations::IMPORTED_MIGRATIONS;
use plume_common::utils::random_hex; use plume_common::utils::random_hex;
use scheduled_thread_pool::ScheduledThreadPool; use scheduled_thread_pool::ScheduledThreadPool;
use search;
use std::env::temp_dir; use std::env::temp_dir;
use std::sync::Arc; use std::sync::Arc;
use Connection as Conn;
use CONFIG;
#[macro_export] #[macro_export]
macro_rules! part_eq { macro_rules! part_eq {

View file

@ -1,17 +1,14 @@
use crate::{
notifications::*, posts::Post, schema::likes, timeline::*, users::User, Connection, Error,
PlumeRocket, Result,
};
use activitypub::activity; use activitypub::activity;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use notifications::*;
use plume_common::activity_pub::{ use plume_common::activity_pub::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
}; };
use posts::Post;
use schema::likes;
use timeline::*;
use users::User;
use {Connection, Error, PlumeRocket, Result};
#[derive(Clone, Queryable, Identifiable)] #[derive(Clone, Queryable, Identifiable)]
pub struct Like { pub struct Like {

View file

@ -1,10 +1,11 @@
use crate::{
blogs::Blog,
schema::{blogs, list_elems, lists, users},
users::User,
Connection, Error, Result,
};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use blogs::Blog;
use schema::{blogs, list_elems, lists, users};
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
use users::User;
use {Connection, Error, Result};
/// Represent what a list is supposed to store. Represented in database as an integer /// Represent what a list is supposed to store. Represented in database as an integer
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -164,7 +165,7 @@ impl List {
last!(lists); last!(lists);
get!(lists); get!(lists);
fn insert(conn: &Connection, val: NewList) -> Result<Self> { fn insert(conn: &Connection, val: NewList<'_>) -> Result<Self> {
diesel::insert_into(lists::table) diesel::insert_into(lists::table)
.values(val) .values(val)
.execute(conn)?; .execute(conn)?;
@ -309,7 +310,7 @@ mod private {
}; };
impl ListElem { impl ListElem {
insert!(list_elems, NewListElem); insert!(list_elems, NewListElem<'_>);
pub fn user_in_list(conn: &Connection, list: &List, user: i32) -> Result<bool> { pub fn user_in_list(conn: &Connection, list: &List, user: i32) -> Result<bool> {
dsl::select(dsl::exists( dsl::select(dsl::exists(
@ -359,9 +360,8 @@ mod private {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use blogs::tests as blog_tests; use crate::{blogs::tests as blog_tests, tests::db};
use diesel::Connection; use diesel::Connection;
use tests::db;
#[test] #[test]
fn list_type() { fn list_type() {

View file

@ -1,20 +1,17 @@
use crate::{
ap_url, instance::Instance, safe_string::SafeString, schema::medias, users::User, Connection,
Error, PlumeRocket, Result,
};
use activitypub::object::Image; use activitypub::object::Image;
use askama_escape::escape; use askama_escape::escape;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use guid_create::GUID; use guid_create::GUID;
use reqwest;
use std::{fs, path::Path};
use plume_common::{ use plume_common::{
activity_pub::{inbox::FromId, Id}, activity_pub::{inbox::FromId, Id},
utils::MediaProcessor, utils::MediaProcessor,
}; };
use reqwest;
use instance::Instance; use std::{fs, path::Path};
use safe_string::SafeString;
use schema::medias;
use users::User;
use {ap_url, Connection, Error, PlumeRocket, Result};
#[derive(Clone, Identifiable, Queryable)] #[derive(Clone, Identifiable, Queryable)]
pub struct Media { pub struct Media {
@ -263,13 +260,11 @@ impl Media {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::{tests::db, users::tests as usersTests, Connection as Conn};
use diesel::Connection; use diesel::Connection;
use std::env::{current_dir, set_current_dir}; use std::env::{current_dir, set_current_dir};
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use tests::db;
use users::tests as usersTests;
use Connection as Conn;
pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Media>) { pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Media>) {
let mut wd = current_dir().unwrap().to_path_buf(); let mut wd = current_dir().unwrap().to_path_buf();

View file

@ -1,14 +1,10 @@
use crate::{
comments::Comment, notifications::*, posts::Post, schema::mentions, users::User, Connection,
Error, PlumeRocket, Result,
};
use activitypub::link; use activitypub::link;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use comments::Comment;
use notifications::*;
use plume_common::activity_pub::inbox::AsActor; use plume_common::activity_pub::inbox::AsActor;
use posts::Post;
use schema::mentions;
use users::User;
use PlumeRocket;
use {Connection, Error, Result};
#[derive(Clone, Queryable, Identifiable)] #[derive(Clone, Queryable, Identifiable)]
pub struct Mention { pub struct Mention {

View file

@ -1,10 +1,6 @@
use Connection; use crate::{Connection, Error, Result};
use Error;
use Result;
use diesel::connection::{Connection as Conn, SimpleConnection}; use diesel::connection::{Connection as Conn, SimpleConnection};
use migrations_internals::{setup_database, MigrationConnection}; use migrations_internals::{setup_database, MigrationConnection};
use std::path::Path; use std::path::Path;
#[allow(dead_code)] //variants might not be constructed if not required by current migrations #[allow(dead_code)] //variants might not be constructed if not required by current migrations

View file

@ -1,16 +1,17 @@
use crate::{
comments::Comment,
follows::Follow,
likes::Like,
mentions::Mention,
posts::Post,
reshares::Reshare,
schema::{follows, notifications},
users::User,
Connection, Error, Result,
};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, JoinOnDsl, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, JoinOnDsl, QueryDsl, RunQueryDsl};
use comments::Comment;
use follows::Follow;
use likes::Like;
use mentions::Mention;
use posts::Post;
use reshares::Reshare;
use schema::{follows, notifications};
use users::User;
use {Connection, Error, Result};
pub mod notification_kind { pub mod notification_kind {
pub const COMMENT: &str = "COMMENT"; pub const COMMENT: &str = "COMMENT";
pub const FOLLOW: &str = "FOLLOW"; pub const FOLLOW: &str = "FOLLOW";

View file

@ -1,7 +1,6 @@
use crate::{schema::password_reset_requests, Connection, Error, Result};
use chrono::{offset::Utc, Duration, NaiveDateTime}; use chrono::{offset::Utc, Duration, NaiveDateTime};
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use schema::password_reset_requests;
use {Connection, Error, Result};
#[derive(Clone, Identifiable, Queryable)] #[derive(Clone, Identifiable, Queryable)]
pub struct PasswordResetRequest { pub struct PasswordResetRequest {
@ -75,9 +74,8 @@ impl PasswordResetRequest {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{tests::db, users::tests as user_tests};
use diesel::Connection; use diesel::Connection;
use tests::db;
use users::tests as user_tests;
#[test] #[test]
fn test_insert_and_find_password_reset_request() { fn test_insert_and_find_password_reset_request() {

View file

@ -2,9 +2,7 @@ pub use self::module::PlumeRocket;
#[cfg(not(test))] #[cfg(not(test))]
mod module { mod module {
use crate::db_conn::DbConn; use crate::{db_conn::DbConn, search, users};
use crate::search;
use crate::users;
use rocket::{ use rocket::{
request::{self, FlashMessage, FromRequest, Request}, request::{self, FlashMessage, FromRequest, Request},
Outcome, State, Outcome, State,
@ -29,9 +27,9 @@ mod module {
let conn = request.guard::<DbConn>()?; let conn = request.guard::<DbConn>()?;
let intl = request.guard::<rocket_i18n::I18n>()?; let intl = request.guard::<rocket_i18n::I18n>()?;
let user = request.guard::<users::User>().succeeded(); let user = request.guard::<users::User>().succeeded();
let worker = request.guard::<State<Arc<ScheduledThreadPool>>>()?; let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?;
let searcher = request.guard::<State<Arc<search::Searcher>>>()?; let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?;
let flash_msg = request.guard::<FlashMessage>().succeeded(); let flash_msg = request.guard::<FlashMessage<'_, '_>>().succeeded();
Outcome::Success(PlumeRocket { Outcome::Success(PlumeRocket {
conn, conn,
intl, intl,
@ -46,9 +44,7 @@ mod module {
#[cfg(test)] #[cfg(test)]
mod module { mod module {
use crate::db_conn::DbConn; use crate::{db_conn::DbConn, search, users};
use crate::search;
use crate::users;
use rocket::{ use rocket::{
request::{self, FromRequest, Request}, request::{self, FromRequest, Request},
Outcome, State, Outcome, State,
@ -70,8 +66,8 @@ mod module {
fn from_request(request: &'a Request<'r>) -> request::Outcome<PlumeRocket, ()> { fn from_request(request: &'a Request<'r>) -> request::Outcome<PlumeRocket, ()> {
let conn = request.guard::<DbConn>()?; let conn = request.guard::<DbConn>()?;
let user = request.guard::<users::User>().succeeded(); let user = request.guard::<users::User>().succeeded();
let worker = request.guard::<State<Arc<ScheduledThreadPool>>>()?; let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?;
let searcher = request.guard::<State<Arc<search::Searcher>>>()?; let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?;
Outcome::Success(PlumeRocket { Outcome::Success(PlumeRocket {
conn, conn,
user, user,

View file

@ -1,10 +1,6 @@
use crate::{posts::Post, schema::post_authors, users::User, Error, Result};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use posts::Post;
use schema::post_authors;
use users::User;
use {Error, Result};
#[derive(Clone, Queryable, Identifiable, Associations)] #[derive(Clone, Queryable, Identifiable, Associations)]
#[belongs_to(Post)] #[belongs_to(Post)]
#[belongs_to(User, foreign_key = "author_id")] #[belongs_to(User, foreign_key = "author_id")]

View file

@ -1,3 +1,8 @@
use crate::{
ap_url, blogs::Blog, instance::Instance, medias::Media, mentions::Mention, post_authors::*,
safe_string::SafeString, schema::posts, search::Searcher, tags::*, timeline::*, users::User,
Connection, Error, PlumeRocket, Result, CONFIG,
};
use activitypub::{ use activitypub::{
activity::{Create, Delete, Update}, activity::{Create, Delete, Update},
link, link,
@ -7,13 +12,6 @@ use activitypub::{
use chrono::{NaiveDateTime, TimeZone, Utc}; use chrono::{NaiveDateTime, TimeZone, Utc};
use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
use heck::{CamelCase, KebabCase}; use heck::{CamelCase, KebabCase};
use serde_json;
use std::collections::HashSet;
use blogs::Blog;
use instance::Instance;
use medias::Media;
use mentions::Mention;
use plume_common::{ use plume_common::{
activity_pub::{ activity_pub::{
inbox::{AsObject, FromId}, inbox::{AsObject, FromId},
@ -21,14 +19,8 @@ use plume_common::{
}, },
utils::md_to_html, utils::md_to_html,
}; };
use post_authors::*; use serde_json;
use safe_string::SafeString; use std::collections::HashSet;
use schema::posts;
use search::Searcher;
use tags::*;
use timeline::*;
use users::User;
use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG};
pub type LicensedArticle = CustomObject<Licensed, Article>; pub type LicensedArticle = CustomObject<Licensed, Article>;
@ -111,7 +103,7 @@ impl Post {
tag: String, tag: String,
(min, max): (i32, i32), (min, max): (i32, i32),
) -> Result<Vec<Post>> { ) -> Result<Vec<Post>> {
use schema::tags; use crate::schema::tags;
let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id); let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id);
posts::table posts::table
@ -125,7 +117,7 @@ impl Post {
} }
pub fn count_for_tag(conn: &Connection, tag: String) -> Result<i64> { pub fn count_for_tag(conn: &Connection, tag: String) -> Result<i64> {
use schema::tags; use crate::schema::tags;
let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id); let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id);
posts::table posts::table
.filter(posts::id.eq_any(ids)) .filter(posts::id.eq_any(ids))
@ -139,8 +131,8 @@ impl Post {
} }
pub fn count_local(conn: &Connection) -> Result<i64> { pub fn count_local(conn: &Connection) -> Result<i64> {
use schema::post_authors; use crate::schema::post_authors;
use schema::users; use crate::schema::users;
let local_authors = users::table let local_authors = users::table
.filter(users::instance_id.eq(Instance::get_local()?.id)) .filter(users::instance_id.eq(Instance::get_local()?.id))
.select(users::id); .select(users::id);
@ -188,7 +180,7 @@ impl Post {
author: &User, author: &User,
limit: i64, limit: i64,
) -> Result<Vec<Post>> { ) -> Result<Vec<Post>> {
use schema::post_authors; use crate::schema::post_authors;
let posts = PostAuthor::belonging_to(author).select(post_authors::post_id); let posts = PostAuthor::belonging_to(author).select(post_authors::post_id);
posts::table posts::table
@ -239,7 +231,7 @@ impl Post {
} }
pub fn drafts_by_author(conn: &Connection, author: &User) -> Result<Vec<Post>> { pub fn drafts_by_author(conn: &Connection, author: &User) -> Result<Vec<Post>> {
use schema::post_authors; use crate::schema::post_authors;
let posts = PostAuthor::belonging_to(author).select(post_authors::post_id); let posts = PostAuthor::belonging_to(author).select(post_authors::post_id);
posts::table posts::table
@ -251,8 +243,8 @@ impl Post {
} }
pub fn get_authors(&self, conn: &Connection) -> Result<Vec<User>> { pub fn get_authors(&self, conn: &Connection) -> Result<Vec<User>> {
use schema::post_authors; use crate::schema::post_authors;
use schema::users; use crate::schema::users;
let author_list = PostAuthor::belonging_to(self).select(post_authors::author_id); let author_list = PostAuthor::belonging_to(self).select(post_authors::author_id);
users::table users::table
.filter(users::id.eq_any(author_list)) .filter(users::id.eq_any(author_list))
@ -261,7 +253,7 @@ impl Post {
} }
pub fn is_author(&self, conn: &Connection, author_id: i32) -> Result<bool> { pub fn is_author(&self, conn: &Connection, author_id: i32) -> Result<bool> {
use schema::post_authors; use crate::schema::post_authors;
Ok(PostAuthor::belonging_to(self) Ok(PostAuthor::belonging_to(self)
.filter(post_authors::author_id.eq(author_id)) .filter(post_authors::author_id.eq(author_id))
.count() .count()
@ -270,7 +262,7 @@ impl Post {
} }
pub fn get_blog(&self, conn: &Connection) -> Result<Blog> { pub fn get_blog(&self, conn: &Connection) -> Result<Blog> {
use schema::blogs; use crate::schema::blogs;
blogs::table blogs::table
.filter(blogs::id.eq(self.blog_id)) .filter(blogs::id.eq(self.blog_id))
.first(conn) .first(conn)
@ -278,7 +270,7 @@ impl Post {
} }
pub fn count_likes(&self, conn: &Connection) -> Result<i64> { pub fn count_likes(&self, conn: &Connection) -> Result<i64> {
use schema::likes; use crate::schema::likes;
likes::table likes::table
.filter(likes::post_id.eq(self.id)) .filter(likes::post_id.eq(self.id))
.count() .count()
@ -287,7 +279,7 @@ impl Post {
} }
pub fn count_reshares(&self, conn: &Connection) -> Result<i64> { pub fn count_reshares(&self, conn: &Connection) -> Result<i64> {
use schema::reshares; use crate::schema::reshares;
reshares::table reshares::table
.filter(reshares::post_id.eq(self.id)) .filter(reshares::post_id.eq(self.id))
.count() .count()

View file

@ -1,17 +1,14 @@
use crate::{
notifications::*, posts::Post, schema::reshares, timeline::*, users::User, Connection, Error,
PlumeRocket, Result,
};
use activitypub::activity::{Announce, Undo}; use activitypub::activity::{Announce, Undo};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use notifications::*;
use plume_common::activity_pub::{ use plume_common::activity_pub::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
Id, IntoId, PUBLIC_VISIBILITY, Id, IntoId, PUBLIC_VISIBILITY,
}; };
use posts::Post;
use schema::reshares;
use timeline::*;
use users::User;
use {Connection, Error, PlumeRocket, Result};
#[derive(Clone, Queryable, Identifiable)] #[derive(Clone, Queryable, Identifiable)]
pub struct Reshare { pub struct Reshare {

View file

@ -82,7 +82,7 @@ lazy_static! {
}; };
} }
fn url_add_prefix(url: &str) -> Option<Cow<str>> { fn url_add_prefix(url: &str) -> Option<Cow<'_, str>> {
if url.starts_with('#') && !url.starts_with("#postcontent-") { if url.starts_with('#') && !url.starts_with("#postcontent-") {
//if start with an # //if start with an #
let mut new_url = "#postcontent-".to_owned(); //change to valid id let mut new_url = "#postcontent-".to_owned(); //change to valid id
@ -139,7 +139,7 @@ struct SafeStringVisitor;
impl<'de> Visitor<'de> for SafeStringVisitor { impl<'de> Visitor<'de> for SafeStringVisitor {
type Value = SafeString; type Value = SafeString;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a string") formatter.write_str("a string")
} }
@ -181,7 +181,7 @@ where
DB: diesel::backend::Backend, DB: diesel::backend::Backend,
str: ToSql<diesel::sql_types::Text, DB>, str: ToSql<diesel::sql_types::Text, DB>,
{ {
fn to_sql<W: Write>(&self, out: &mut Output<W, DB>) -> serialize::Result { fn to_sql<W: Write>(&self, out: &mut Output<'_, W, DB>) -> serialize::Result {
str::to_sql(&self.value, out) str::to_sql(&self.value, out)
} }
} }
@ -193,7 +193,7 @@ impl Borrow<str> for SafeString {
} }
impl Display for SafeString { impl Display for SafeString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.value) write!(f, "{}", self.value)
} }
} }

View file

@ -8,15 +8,17 @@ pub use self::searcher::*;
pub(crate) mod tests { pub(crate) mod tests {
use super::{Query, Searcher}; use super::{Query, Searcher};
use diesel::Connection; use diesel::Connection;
use plume_common::utils::random_hex;
use std::env::temp_dir; use std::env::temp_dir;
use std::str::FromStr; use std::str::FromStr;
use blogs::tests::fill_database; use crate::{
use plume_common::utils::random_hex; blogs::tests::fill_database,
use post_authors::*; post_authors::*,
use posts::{NewPost, Post}; posts::{NewPost, Post},
use safe_string::SafeString; safe_string::SafeString,
use tests::db; tests::db,
};
pub(crate) fn get_searcher() -> Searcher { pub(crate) fn get_searcher() -> Searcher {
let dir = temp_dir().join(&format!("plume-test-{}", random_hex())); let dir = temp_dir().join(&format!("plume-test-{}", random_hex()));

View file

@ -1,5 +1,5 @@
use crate::search::searcher::Searcher;
use chrono::{naive::NaiveDate, offset::Utc, Datelike}; use chrono::{naive::NaiveDate, offset::Utc, Datelike};
use search::searcher::Searcher;
use std::{cmp, ops::Bound}; use std::{cmp, ops::Bound};
use tantivy::{query::*, schema::*, Term}; use tantivy::{query::*, schema::*, Term};

View file

@ -1,9 +1,11 @@
use instance::Instance; use crate::{
use posts::Post; instance::Instance,
use schema::posts; posts::Post,
use tags::Tag; schema::posts,
use Connection; search::{query::PlumeQuery, tokenizer},
tags::Tag,
Connection, Result,
};
use chrono::Datelike; use chrono::Datelike;
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use itertools::Itertools; use itertools::Itertools;
@ -14,10 +16,6 @@ use tantivy::{
}; };
use whatlang::{detect as detect_lang, Lang}; use whatlang::{detect as detect_lang, Lang};
use super::tokenizer;
use search::query::PlumeQuery;
use Result;
#[derive(Debug)] #[derive(Debug)]
pub enum SearcherError { pub enum SearcherError {
IndexCreationError, IndexCreationError,

View file

@ -1,9 +1,6 @@
use crate::{ap_url, instance::Instance, schema::tags, Connection, Error, Result};
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use instance::Instance;
use plume_common::activity_pub::Hashtag; use plume_common::activity_pub::Hashtag;
use schema::tags;
use {ap_url, Connection, Error, Result};
#[derive(Clone, Identifiable, Queryable)] #[derive(Clone, Identifiable, Queryable)]
pub struct Tag { pub struct Tag {

View file

@ -1,16 +1,16 @@
use crate::{
lists::List,
posts::Post,
schema::{posts, timeline, timeline_definition},
Connection, Error, PlumeRocket, Result,
};
use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl}; use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl};
use lists::List;
use posts::Post;
use schema::{posts, timeline, timeline_definition};
use std::ops::Deref; use std::ops::Deref;
use {Connection, Error, PlumeRocket, Result};
pub(crate) mod query; pub(crate) mod query;
use self::query::{QueryError, TimelineQuery};
pub use self::query::Kind; pub use self::query::Kind;
use self::query::{QueryError, TimelineQuery};
#[derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)] #[derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)]
#[table_name = "timeline_definition"] #[table_name = "timeline_definition"]
@ -208,7 +208,7 @@ impl Timeline {
.map_err(Error::from) .map_err(Error::from)
} }
pub fn add_to_all_timelines(rocket: &PlumeRocket, post: &Post, kind: Kind) -> Result<()> { pub fn add_to_all_timelines(rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<()> {
let timelines = timeline_definition::table let timelines = timeline_definition::table
.load::<Self>(rocket.conn.deref()) .load::<Self>(rocket.conn.deref())
.map_err(Error::from)?; .map_err(Error::from)?;
@ -231,7 +231,7 @@ impl Timeline {
Ok(()) Ok(())
} }
pub fn matches(&self, rocket: &PlumeRocket, post: &Post, kind: Kind) -> Result<bool> { pub fn matches(&self, rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<bool> {
let query = TimelineQuery::parse(&self.query)?; let query = TimelineQuery::parse(&self.query)?;
query.matches(rocket, self, post, kind) query.matches(rocket, self, post, kind)
} }
@ -240,16 +240,18 @@ impl Timeline {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use blogs::tests as blogTests; use crate::{
blogs::tests as blogTests,
follows::*,
lists::ListType,
post_authors::{NewPostAuthor, PostAuthor},
posts::NewPost,
safe_string::SafeString,
tags::Tag,
tests::{db, rockets},
users::tests as userTests,
};
use diesel::Connection; use diesel::Connection;
use follows::*;
use lists::ListType;
use post_authors::{NewPostAuthor, PostAuthor};
use posts::NewPost;
use safe_string::SafeString;
use tags::Tag;
use tests::{db, rockets};
use users::tests as userTests;
#[test] #[test]
fn test_timeline() { fn test_timeline() {

View file

@ -1,15 +1,15 @@
use blogs::Blog; use crate::{
use lists::{self, ListType}; blogs::Blog,
lists::{self, ListType},
posts::Post,
tags::Tag,
timeline::Timeline,
users::User,
PlumeRocket, Result,
};
use plume_common::activity_pub::inbox::AsActor; use plume_common::activity_pub::inbox::AsActor;
use posts::Post;
use tags::Tag;
use users::User;
use whatlang::{self, Lang}; use whatlang::{self, Lang};
use {PlumeRocket, Result};
use super::Timeline;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum QueryError { pub enum QueryError {
SyntaxError(usize, usize, String), SyntaxError(usize, usize, String),
@ -65,7 +65,7 @@ impl<'a> Token<'a> {
} }
} }
fn get_error<T>(&self, token: Token) -> QueryResult<T> { fn get_error<T>(&self, token: Token<'_>) -> QueryResult<T> {
let (b, e) = self.get_pos(); let (b, e) = self.get_pos();
let message = format!( let message = format!(
"Syntax Error: Expected {}, got {}", "Syntax Error: Expected {}, got {}",
@ -127,7 +127,7 @@ macro_rules! gen_tokenizer {
} }
} }
fn lex(stream: &str) -> Vec<Token> { fn lex(stream: &str) -> Vec<Token<'_>> {
stream stream
.chars() .chars()
.chain(" ".chars()) // force a last whitespace to empty scan's state .chain(" ".chars()) // force a last whitespace to empty scan's state
@ -163,7 +163,7 @@ impl<'a> TQ<'a> {
rocket: &PlumeRocket, rocket: &PlumeRocket,
timeline: &Timeline, timeline: &Timeline,
post: &Post, post: &Post,
kind: Kind, kind: Kind<'_>,
) -> Result<bool> { ) -> Result<bool> {
match self { match self {
TQ::Or(inner) => inner.iter().try_fold(false, |s, e| { TQ::Or(inner) => inner.iter().try_fold(false, |s, e| {
@ -208,7 +208,7 @@ impl<'a> Arg<'a> {
rocket: &PlumeRocket, rocket: &PlumeRocket,
timeline: &Timeline, timeline: &Timeline,
post: &Post, post: &Post,
kind: Kind, kind: Kind<'_>,
) -> Result<bool> { ) -> Result<bool> {
match self { match self {
Arg::In(t, l) => t.matches(rocket, timeline, post, l, kind), Arg::In(t, l) => t.matches(rocket, timeline, post, l, kind),
@ -233,8 +233,8 @@ impl WithList {
rocket: &PlumeRocket, rocket: &PlumeRocket,
timeline: &Timeline, timeline: &Timeline,
post: &Post, post: &Post,
list: &List, list: &List<'_>,
kind: Kind, kind: Kind<'_>,
) -> Result<bool> { ) -> Result<bool> {
match list { match list {
List::List(name) => { List::List(name) => {
@ -374,7 +374,7 @@ impl Bool {
rocket: &PlumeRocket, rocket: &PlumeRocket,
timeline: &Timeline, timeline: &Timeline,
post: &Post, post: &Post,
kind: Kind, kind: Kind<'_>,
) -> Result<bool> { ) -> Result<bool> {
match self { match self {
Bool::Followed { boosts, likes } => { Bool::Followed { boosts, likes } => {
@ -645,7 +645,7 @@ impl<'a> TimelineQuery<'a> {
rocket: &PlumeRocket, rocket: &PlumeRocket,
timeline: &Timeline, timeline: &Timeline,
post: &Post, post: &Post,
kind: Kind, kind: Kind<'_>,
) -> Result<bool> { ) -> Result<bool> {
self.0.matches(rocket, timeline, post, kind) self.0.matches(rocket, timeline, post, kind)
} }

View file

@ -1,3 +1,9 @@
use crate::{
ap_url, blocklisted_emails::BlocklistedEmail, blogs::Blog, db_conn::DbConn, follows::Follow,
instance::*, medias::Media, notifications::Notification, post_authors::PostAuthor, posts::Post,
safe_string::SafeString, schema::users, search::Searcher, timeline::Timeline, Connection,
Error, PlumeRocket, Result, ITEMS_PER_PAGE,
};
use activitypub::{ use activitypub::{
activity::Delete, activity::Delete,
actor::Person, actor::Person,
@ -14,13 +20,15 @@ use openssl::{
rsa::Rsa, rsa::Rsa,
sign, sign,
}; };
use plume_common::activity_pub::{ use plume_common::{
activity_pub::{
ap_accept_header, ap_accept_header,
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
sign::{gen_keypair, Signer}, sign::{gen_keypair, Signer},
ActivityStream, ApSignature, Id, IntoId, PublicKey, PUBLIC_VISIBILITY, ActivityStream, ApSignature, Id, IntoId, PublicKey, PUBLIC_VISIBILITY,
},
utils,
}; };
use plume_common::utils;
use reqwest::{ use reqwest::{
header::{HeaderValue, ACCEPT}, header::{HeaderValue, ACCEPT},
ClientBuilder, ClientBuilder,
@ -37,23 +45,6 @@ use std::{
use url::Url; use url::Url;
use webfinger::*; use webfinger::*;
use blogs::Blog;
use db_conn::DbConn;
use follows::Follow;
use instance::*;
use medias::Media;
use notifications::Notification;
use post_authors::PostAuthor;
use posts::Post;
use safe_string::SafeString;
use schema::users;
use search::Searcher;
use timeline::Timeline;
use {
ap_url, blocklisted_emails::BlocklistedEmail, Connection, Error, PlumeRocket, Result,
ITEMS_PER_PAGE,
};
pub type CustomPerson = CustomObject<ApSignature, Person>; pub type CustomPerson = CustomObject<ApSignature, Person>;
pub enum Role { pub enum Role {
@ -139,7 +130,7 @@ impl User {
} }
pub fn delete(&self, conn: &Connection, searcher: &Searcher) -> Result<()> { pub fn delete(&self, conn: &Connection, searcher: &Searcher) -> Result<()> {
use schema::post_authors; use crate::schema::post_authors;
for blog in Blog::find_for_author(conn, self)? for blog in Blog::find_for_author(conn, self)?
.iter() .iter()
@ -464,8 +455,8 @@ impl User {
.collect::<Vec<String>>()) .collect::<Vec<String>>())
} }
fn get_activities_count(&self, conn: &Connection) -> i64 { fn get_activities_count(&self, conn: &Connection) -> i64 {
use schema::post_authors; use crate::schema::post_authors;
use schema::posts; use crate::schema::posts;
let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id); let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id);
posts::table posts::table
.filter(posts::published.eq(true)) .filter(posts::published.eq(true))
@ -479,8 +470,8 @@ impl User {
conn: &Connection, conn: &Connection,
(min, max): (i32, i32), (min, max): (i32, i32),
) -> Result<Vec<serde_json::Value>> { ) -> Result<Vec<serde_json::Value>> {
use schema::post_authors; use crate::schema::post_authors;
use schema::posts; use crate::schema::posts;
let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id); let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id);
let posts = posts::table let posts = posts::table
.filter(posts::published.eq(true)) .filter(posts::published.eq(true))
@ -500,7 +491,7 @@ impl User {
} }
pub fn get_followers(&self, conn: &Connection) -> Result<Vec<User>> { pub fn get_followers(&self, conn: &Connection) -> Result<Vec<User>> {
use schema::follows; use crate::schema::follows;
let follows = Follow::belonging_to(self).select(follows::follower_id); let follows = Follow::belonging_to(self).select(follows::follower_id);
users::table users::table
.filter(users::id.eq_any(follows)) .filter(users::id.eq_any(follows))
@ -509,7 +500,7 @@ impl User {
} }
pub fn count_followers(&self, conn: &Connection) -> Result<i64> { pub fn count_followers(&self, conn: &Connection) -> Result<i64> {
use schema::follows; use crate::schema::follows;
let follows = Follow::belonging_to(self).select(follows::follower_id); let follows = Follow::belonging_to(self).select(follows::follower_id);
users::table users::table
.filter(users::id.eq_any(follows)) .filter(users::id.eq_any(follows))
@ -523,7 +514,7 @@ impl User {
conn: &Connection, conn: &Connection,
(min, max): (i32, i32), (min, max): (i32, i32),
) -> Result<Vec<User>> { ) -> Result<Vec<User>> {
use schema::follows; use crate::schema::follows;
let follows = Follow::belonging_to(self).select(follows::follower_id); let follows = Follow::belonging_to(self).select(follows::follower_id);
users::table users::table
.filter(users::id.eq_any(follows)) .filter(users::id.eq_any(follows))
@ -534,7 +525,7 @@ impl User {
} }
pub fn get_followed(&self, conn: &Connection) -> Result<Vec<User>> { pub fn get_followed(&self, conn: &Connection) -> Result<Vec<User>> {
use schema::follows::dsl::*; use crate::schema::follows::dsl::*;
let f = follows.filter(follower_id.eq(self.id)).select(following_id); let f = follows.filter(follower_id.eq(self.id)).select(following_id);
users::table users::table
.filter(users::id.eq_any(f)) .filter(users::id.eq_any(f))
@ -543,7 +534,7 @@ impl User {
} }
pub fn count_followed(&self, conn: &Connection) -> Result<i64> { pub fn count_followed(&self, conn: &Connection) -> Result<i64> {
use schema::follows; use crate::schema::follows;
follows::table follows::table
.filter(follows::follower_id.eq(self.id)) .filter(follows::follower_id.eq(self.id))
.count() .count()
@ -556,7 +547,7 @@ impl User {
conn: &Connection, conn: &Connection,
(min, max): (i32, i32), (min, max): (i32, i32),
) -> Result<Vec<User>> { ) -> Result<Vec<User>> {
use schema::follows; use crate::schema::follows;
let follows = follows::table let follows = follows::table
.filter(follows::follower_id.eq(self.id)) .filter(follows::follower_id.eq(self.id))
.select(follows::following_id) .select(follows::following_id)
@ -569,7 +560,7 @@ impl User {
} }
pub fn is_followed_by(&self, conn: &Connection, other_id: i32) -> Result<bool> { pub fn is_followed_by(&self, conn: &Connection, other_id: i32) -> Result<bool> {
use schema::follows; use crate::schema::follows;
follows::table follows::table
.filter(follows::follower_id.eq(other_id)) .filter(follows::follower_id.eq(other_id))
.filter(follows::following_id.eq(self.id)) .filter(follows::following_id.eq(self.id))
@ -580,7 +571,7 @@ impl User {
} }
pub fn is_following(&self, conn: &Connection, other_id: i32) -> Result<bool> { pub fn is_following(&self, conn: &Connection, other_id: i32) -> Result<bool> {
use schema::follows; use crate::schema::follows;
follows::table follows::table
.filter(follows::follower_id.eq(self.id)) .filter(follows::follower_id.eq(self.id))
.filter(follows::following_id.eq(other_id)) .filter(follows::following_id.eq(other_id))
@ -591,7 +582,7 @@ impl User {
} }
pub fn has_liked(&self, conn: &Connection, post: &Post) -> Result<bool> { pub fn has_liked(&self, conn: &Connection, post: &Post) -> Result<bool> {
use schema::likes; use crate::schema::likes;
likes::table likes::table
.filter(likes::post_id.eq(post.id)) .filter(likes::post_id.eq(post.id))
.filter(likes::user_id.eq(self.id)) .filter(likes::user_id.eq(self.id))
@ -602,7 +593,7 @@ impl User {
} }
pub fn has_reshared(&self, conn: &Connection, post: &Post) -> Result<bool> { pub fn has_reshared(&self, conn: &Connection, post: &Post) -> Result<bool> {
use schema::reshares; use crate::schema::reshares;
reshares::table reshares::table
.filter(reshares::post_id.eq(post.id)) .filter(reshares::post_id.eq(post.id))
.filter(reshares::user_id.eq(self.id)) .filter(reshares::user_id.eq(self.id))
@ -613,7 +604,7 @@ impl User {
} }
pub fn is_author_in(&self, conn: &Connection, blog: &Blog) -> Result<bool> { pub fn is_author_in(&self, conn: &Connection, blog: &Blog) -> Result<bool> {
use schema::blog_authors; use crate::schema::blog_authors;
blog_authors::table blog_authors::table
.filter(blog_authors::author_id.eq(self.id)) .filter(blog_authors::author_id.eq(self.id))
.filter(blog_authors::blog_id.eq(blog.id)) .filter(blog_authors::blog_id.eq(blog.id))
@ -1033,11 +1024,13 @@ impl NewUser {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::{
instance::{tests as instance_tests, Instance},
search::tests::get_searcher,
tests::{db, rockets},
Connection as Conn,
};
use diesel::Connection; use diesel::Connection;
use instance::{tests as instance_tests, Instance};
use search::tests::get_searcher;
use tests::{db, rockets};
use Connection as Conn;
pub(crate) fn fill_database(conn: &Conn) -> Vec<User> { pub(crate) fn fill_database(conn: &Conn) -> Vec<User> {
instance_tests::fill_database(conn); instance_tests::fill_database(conn);

View file

@ -1,7 +1,3 @@
extern crate diesel;
extern crate plume_common;
extern crate plume_models;
use diesel::Connection; use diesel::Connection;
use plume_common::utils::random_hex; use plume_common::utils::random_hex;
use plume_models::migrations::IMPORTED_MIGRATIONS; use plume_models::migrations::IMPORTED_MIGRATIONS;

View file

@ -27,7 +27,7 @@ impl From<std::option::NoneError> for ApiError {
} }
impl<'r> Responder<'r> for ApiError { impl<'r> Responder<'r> for ApiError {
fn respond_to(self, req: &Request) -> response::Result<'r> { fn respond_to(self, req: &Request<'_>) -> response::Result<'r> {
match self.0 { match self.0 {
Error::NotFound => Json(json!({ Error::NotFound => Json(json!({
"error": "Not found" "error": "Not found"

View file

@ -14,7 +14,7 @@ use std::io::Read;
pub fn handle_incoming( pub fn handle_incoming(
rockets: PlumeRocket, rockets: PlumeRocket,
data: SignedJson<serde_json::Value>, data: SignedJson<serde_json::Value>,
headers: Headers, headers: Headers<'_>,
) -> Result<String, status::BadRequest<&'static str>> { ) -> Result<String, status::BadRequest<&'static str>> {
let conn = &*rockets.conn; let conn = &*rockets.conn;
let act = data.1.into_inner(); let act = data.1.into_inner();
@ -74,7 +74,7 @@ impl<'a, T: Deserialize<'a>> FromData<'a> for SignedJson<T> {
type Borrowed = str; type Borrowed = str;
fn transform( fn transform(
r: &Request, r: &Request<'_>,
d: Data, d: Data,
) -> Transform<rocket::data::Outcome<Self::Owned, Self::Error>> { ) -> Transform<rocket::data::Outcome<Self::Owned, Self::Error>> {
let size_limit = r.limits().get("json").unwrap_or(JSON_LIMIT); let size_limit = r.limits().get("json").unwrap_or(JSON_LIMIT);
@ -86,7 +86,7 @@ impl<'a, T: Deserialize<'a>> FromData<'a> for SignedJson<T> {
} }
fn from_data( fn from_data(
_: &Request, _: &Request<'_>,
o: Transformed<'a, Self>, o: Transformed<'a, Self>,
) -> rocket::data::Outcome<Self, Self::Error> { ) -> rocket::data::Outcome<Self, Self::Error> {
let string = o.borrowed()?; let string = o.borrowed()?;

View file

@ -1,43 +1,16 @@
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
#![feature(decl_macro, proc_macro_hygiene, try_trait)] #![feature(decl_macro, proc_macro_hygiene, try_trait)]
extern crate activitypub;
extern crate askama_escape;
extern crate atom_syndication;
extern crate chrono;
extern crate clap;
extern crate colored;
extern crate ctrlc;
extern crate diesel;
extern crate dotenv;
#[macro_use] #[macro_use]
extern crate gettext_macros; extern crate gettext_macros;
extern crate gettext_utils;
extern crate guid_create;
extern crate heck;
extern crate lettre;
extern crate lettre_email;
extern crate multipart;
extern crate num_cpus;
extern crate plume_api;
extern crate plume_common;
extern crate plume_models;
#[macro_use] #[macro_use]
extern crate rocket; extern crate rocket;
extern crate rocket_contrib;
extern crate rocket_csrf;
extern crate rocket_i18n;
#[macro_use] #[macro_use]
extern crate runtime_fmt; extern crate runtime_fmt;
extern crate scheduled_thread_pool;
extern crate serde;
#[macro_use] #[macro_use]
extern crate serde_json; extern crate serde_json;
extern crate serde_qs;
extern crate validator;
#[macro_use] #[macro_use]
extern crate validator_derive; extern crate validator_derive;
extern crate webfinger;
use clap::App; use clap::App;
use diesel::r2d2::ConnectionManager; use diesel::r2d2::ConnectionManager;

View file

@ -10,14 +10,14 @@ use rocket_i18n::I18n;
use std::{borrow::Cow, collections::HashMap}; use std::{borrow::Cow, collections::HashMap};
use validator::{Validate, ValidationError, ValidationErrors}; use validator::{Validate, ValidationError, ValidationErrors};
use crate::routes::{errors::ErrorPage, Page, RespondOrRedirect};
use crate::template_utils::{IntoContext, Ructe};
use plume_common::activity_pub::{ActivityStream, ApRequest}; use plume_common::activity_pub::{ActivityStream, ApRequest};
use plume_common::utils; use plume_common::utils;
use plume_models::{ use plume_models::{
blog_authors::*, blogs::*, instance::Instance, medias::*, posts::Post, safe_string::SafeString, blog_authors::*, blogs::*, instance::Instance, medias::*, posts::Post, safe_string::SafeString,
users::User, Connection, PlumeRocket, users::User, Connection, PlumeRocket,
}; };
use routes::{errors::ErrorPage, Page, RespondOrRedirect};
use template_utils::{IntoContext, Ructe};
#[get("/~/<name>?<page>", rank = 2)] #[get("/~/<name>?<page>", rank = 2)]
pub fn details(name: String, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> { pub fn details(name: String, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {

View file

@ -1,13 +1,15 @@
use crate::template_utils::Ructe;
use activitypub::object::Note; use activitypub::object::Note;
use rocket::{ use rocket::{
request::LenientForm, request::LenientForm,
response::{Flash, Redirect}, response::{Flash, Redirect},
}; };
use template_utils::Ructe;
use validator::Validate; use validator::Validate;
use std::time::Duration; use std::time::Duration;
use crate::routes::errors::ErrorPage;
use crate::template_utils::IntoContext;
use plume_common::{ use plume_common::{
activity_pub::{broadcast, ActivityStream, ApRequest}, activity_pub::{broadcast, ActivityStream, ApRequest},
utils, utils,
@ -16,8 +18,6 @@ use plume_models::{
blogs::Blog, comments::*, inbox::inbox, instance::Instance, medias::Media, mentions::Mention, blogs::Blog, comments::*, inbox::inbox, instance::Instance, medias::Media, mentions::Mention,
posts::Post, safe_string::SafeString, tags::Tag, users::User, Error, PlumeRocket, posts::Post, safe_string::SafeString, tags::Tag, users::User, Error, PlumeRocket,
}; };
use routes::errors::ErrorPage;
use template_utils::IntoContext;
#[derive(Default, FromForm, Debug, Validate)] #[derive(Default, FromForm, Debug, Validate)]
pub struct NewCommentForm { pub struct NewCommentForm {

View file

@ -1,9 +1,9 @@
use crate::template_utils::{IntoContext, Ructe};
use plume_models::{Error, PlumeRocket}; use plume_models::{Error, PlumeRocket};
use rocket::{ use rocket::{
response::{self, Responder}, response::{self, Responder},
Request, Request,
}; };
use template_utils::{IntoContext, Ructe};
#[derive(Debug)] #[derive(Debug)]
pub struct ErrorPage(Error); pub struct ErrorPage(Error);
@ -15,7 +15,7 @@ impl From<Error> for ErrorPage {
} }
impl<'r> Responder<'r> for ErrorPage { impl<'r> Responder<'r> for ErrorPage {
fn respond_to(self, req: &Request) -> response::Result<'r> { fn respond_to(self, req: &Request<'_>) -> response::Result<'r> {
let rockets = req.guard::<PlumeRocket>().unwrap(); let rockets = req.guard::<PlumeRocket>().unwrap();
match self.0 { match self.0 {
@ -29,19 +29,19 @@ impl<'r> Responder<'r> for ErrorPage {
} }
#[catch(404)] #[catch(404)]
pub fn not_found(req: &Request) -> Ructe { pub fn not_found(req: &Request<'_>) -> Ructe {
let rockets = req.guard::<PlumeRocket>().unwrap(); let rockets = req.guard::<PlumeRocket>().unwrap();
render!(errors::not_found(&rockets.to_context())) render!(errors::not_found(&rockets.to_context()))
} }
#[catch(422)] #[catch(422)]
pub fn unprocessable_entity(req: &Request) -> Ructe { pub fn unprocessable_entity(req: &Request<'_>) -> Ructe {
let rockets = req.guard::<PlumeRocket>().unwrap(); let rockets = req.guard::<PlumeRocket>().unwrap();
render!(errors::unprocessable_entity(&rockets.to_context())) render!(errors::unprocessable_entity(&rockets.to_context()))
} }
#[catch(500)] #[catch(500)]
pub fn server_error(req: &Request) -> Ructe { pub fn server_error(req: &Request<'_>) -> Ructe {
let rockets = req.guard::<PlumeRocket>().unwrap(); let rockets = req.guard::<PlumeRocket>().unwrap();
render!(errors::server_error(&rockets.to_context())) render!(errors::server_error(&rockets.to_context()))
} }

View file

@ -9,7 +9,9 @@ use serde_json;
use std::str::FromStr; use std::str::FromStr;
use validator::{Validate, ValidationErrors}; use validator::{Validate, ValidationErrors};
use inbox; use crate::inbox;
use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect};
use crate::template_utils::{IntoContext, Ructe};
use plume_common::activity_pub::{broadcast, inbox::FromId}; use plume_common::activity_pub::{broadcast, inbox::FromId};
use plume_models::{ use plume_models::{
admin::*, admin::*,
@ -25,8 +27,6 @@ use plume_models::{
users::{Role, User}, users::{Role, User},
Connection, Error, PlumeRocket, CONFIG, Connection, Error, PlumeRocket, CONFIG,
}; };
use routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect};
use template_utils::{IntoContext, Ructe};
#[get("/")] #[get("/")]
pub fn index(rockets: PlumeRocket) -> Result<Ructe, ErrorPage> { pub fn index(rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {
@ -248,7 +248,7 @@ where
{ {
type Error = (); type Error = ();
fn from_form(items: &mut FormItems, _strict: bool) -> Result<Self, Self::Error> { fn from_form(items: &mut FormItems<'_>, _strict: bool) -> Result<Self, Self::Error> {
let (ids, act) = items.fold((vec![], None), |(mut ids, act), item| { let (ids, act) = items.fold((vec![], None), |(mut ids, act), item| {
let (name, val) = item.key_value_decoded(); let (name, val) = item.key_value_decoded();
@ -389,7 +389,7 @@ fn ban(
pub fn shared_inbox( pub fn shared_inbox(
rockets: PlumeRocket, rockets: PlumeRocket,
data: inbox::SignedJson<serde_json::Value>, data: inbox::SignedJson<serde_json::Value>,
headers: Headers, headers: Headers<'_>,
) -> Result<String, status::BadRequest<&'static str>> { ) -> Result<String, status::BadRequest<&'static str>> {
inbox::handle_incoming(rockets, data, headers) inbox::handle_incoming(rockets, data, headers)
} }

View file

@ -1,12 +1,12 @@
use rocket::response::{Flash, Redirect}; use rocket::response::{Flash, Redirect};
use rocket_i18n::I18n; use rocket_i18n::I18n;
use crate::routes::errors::ErrorPage;
use plume_common::activity_pub::broadcast; use plume_common::activity_pub::broadcast;
use plume_common::utils; use plume_common::utils;
use plume_models::{ use plume_models::{
blogs::Blog, inbox::inbox, likes, posts::Post, timeline::*, users::User, Error, PlumeRocket, blogs::Blog, inbox::inbox, likes, posts::Post, timeline::*, users::User, Error, PlumeRocket,
}; };
use routes::errors::ErrorPage;
#[post("/~/<blog>/<slug>/like")] #[post("/~/<blog>/<slug>/like")]
pub fn create( pub fn create(

View file

@ -1,3 +1,5 @@
use crate::routes::{errors::ErrorPage, Page};
use crate::template_utils::{IntoContext, Ructe};
use guid_create::GUID; use guid_create::GUID;
use multipart::server::{ use multipart::server::{
save::{SaveResult, SavedData}, save::{SaveResult, SavedData},
@ -10,9 +12,7 @@ use rocket::{
Data, Data,
}; };
use rocket_i18n::I18n; use rocket_i18n::I18n;
use routes::{errors::ErrorPage, Page};
use std::fs; use std::fs;
use template_utils::{IntoContext, Ructe};
#[get("/medias?<page>")] #[get("/medias?<page>")]
pub fn list(user: User, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> { pub fn list(user: User, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {

View file

@ -1,4 +1,5 @@
#![warn(clippy::too_many_arguments)] #![warn(clippy::too_many_arguments)]
use crate::template_utils::Ructe;
use atom_syndication::{ContentBuilder, Entry, EntryBuilder, LinkBuilder, Person, PersonBuilder}; use atom_syndication::{ContentBuilder, Entry, EntryBuilder, LinkBuilder, Person, PersonBuilder};
use plume_models::{posts::Post, Connection, CONFIG, ITEMS_PER_PAGE}; use plume_models::{posts::Post, Connection, CONFIG, ITEMS_PER_PAGE};
use rocket::{ use rocket::{
@ -16,7 +17,6 @@ use std::{
hash::Hasher, hash::Hasher,
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use template_utils::Ructe;
/// Special return type used for routes that "cannot fail", and instead /// Special return type used for routes that "cannot fail", and instead
/// `Redirect`, or `Flash<Redirect>`, when we cannot deliver a `Ructe` Response /// `Redirect`, or `Flash<Redirect>`, when we cannot deliver a `Ructe` Response
@ -178,7 +178,7 @@ pub struct CachedFile {
pub struct ThemeFile(NamedFile); pub struct ThemeFile(NamedFile);
impl<'r> Responder<'r> for ThemeFile { impl<'r> Responder<'r> for ThemeFile {
fn respond_to(self, r: &Request) -> response::Result<'r> { fn respond_to(self, r: &Request<'_>) -> response::Result<'r> {
let contents = std::fs::read(self.0.path()).map_err(|_| Status::InternalServerError)?; let contents = std::fs::read(self.0.path()).map_err(|_| Status::InternalServerError)?;
let mut hasher = DefaultHasher::new(); let mut hasher = DefaultHasher::new();

View file

@ -1,10 +1,10 @@
use rocket::response::{Flash, Redirect}; use rocket::response::{Flash, Redirect};
use rocket_i18n::I18n; use rocket_i18n::I18n;
use crate::routes::{errors::ErrorPage, Page};
use crate::template_utils::{IntoContext, Ructe};
use plume_common::utils; use plume_common::utils;
use plume_models::{notifications::Notification, users::User, PlumeRocket}; use plume_models::{notifications::Notification, users::User, PlumeRocket};
use routes::{errors::ErrorPage, Page};
use template_utils::{IntoContext, Ructe};
#[get("/notifications?<page>")] #[get("/notifications?<page>")]
pub fn notifications( pub fn notifications(

View file

@ -10,6 +10,10 @@ use std::{
}; };
use validator::{Validate, ValidationError, ValidationErrors}; use validator::{Validate, ValidationError, ValidationErrors};
use crate::routes::{
comments::NewCommentForm, errors::ErrorPage, ContentLen, RemoteForm, RespondOrRedirect,
};
use crate::template_utils::{IntoContext, Ructe};
use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest}; use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest};
use plume_common::utils; use plume_common::utils;
use plume_models::{ use plume_models::{
@ -27,10 +31,6 @@ use plume_models::{
users::User, users::User,
Error, PlumeRocket, Error, PlumeRocket,
}; };
use routes::{
comments::NewCommentForm, errors::ErrorPage, ContentLen, RemoteForm, RespondOrRedirect,
};
use template_utils::{IntoContext, Ructe};
#[get("/~/<blog>/<slug>?<responding_to>", rank = 4)] #[get("/~/<blog>/<slug>?<responding_to>", rank = 4)]
pub fn details( pub fn details(

View file

@ -1,13 +1,13 @@
use rocket::response::{Flash, Redirect}; use rocket::response::{Flash, Redirect};
use rocket_i18n::I18n; use rocket_i18n::I18n;
use crate::routes::errors::ErrorPage;
use plume_common::activity_pub::broadcast; use plume_common::activity_pub::broadcast;
use plume_common::utils; use plume_common::utils;
use plume_models::{ use plume_models::{
blogs::Blog, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User, Error, blogs::Blog, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User, Error,
PlumeRocket, PlumeRocket,
}; };
use routes::errors::ErrorPage;
#[post("/~/<blog>/<slug>/reshare")] #[post("/~/<blog>/<slug>/reshare")]
pub fn create( pub fn create(

View file

@ -1,10 +1,10 @@
use chrono::offset::Utc; use chrono::offset::Utc;
use rocket::request::Form; use rocket::request::Form;
use crate::routes::Page;
use crate::template_utils::{IntoContext, Ructe};
use plume_models::{search::Query, PlumeRocket}; use plume_models::{search::Query, PlumeRocket};
use routes::Page;
use std::str::FromStr; use std::str::FromStr;
use template_utils::{IntoContext, Ructe};
#[derive(Default, FromForm)] #[derive(Default, FromForm)]
pub struct SearchQuery { pub struct SearchQuery {

View file

@ -1,3 +1,4 @@
use crate::routes::RespondOrRedirect;
use lettre::Transport; use lettre::Transport;
use rocket::http::ext::IntoOwned; use rocket::http::ext::IntoOwned;
use rocket::{ use rocket::{
@ -7,7 +8,6 @@ use rocket::{
State, State,
}; };
use rocket_i18n::I18n; use rocket_i18n::I18n;
use routes::RespondOrRedirect;
use std::{ use std::{
borrow::Cow, borrow::Cow,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
@ -15,13 +15,13 @@ use std::{
}; };
use validator::{Validate, ValidationError, ValidationErrors}; use validator::{Validate, ValidationError, ValidationErrors};
use mail::{build_mail, Mailer}; use crate::mail::{build_mail, Mailer};
use crate::template_utils::{IntoContext, Ructe};
use plume_models::{ use plume_models::{
password_reset_requests::*, password_reset_requests::*,
users::{User, AUTH_COOKIE}, users::{User, AUTH_COOKIE},
Error, PlumeRocket, CONFIG, Error, PlumeRocket, CONFIG,
}; };
use template_utils::{IntoContext, Ructe};
#[get("/login?<m>")] #[get("/login?<m>")]
pub fn new(m: Option<String>, rockets: PlumeRocket) -> Ructe { pub fn new(m: Option<String>, rockets: PlumeRocket) -> Ructe {
@ -44,7 +44,7 @@ pub struct LoginForm {
#[post("/login", data = "<form>")] #[post("/login", data = "<form>")]
pub fn create( pub fn create(
form: LenientForm<LoginForm>, form: LenientForm<LoginForm>,
mut cookies: Cookies, mut cookies: Cookies<'_>,
rockets: PlumeRocket, rockets: PlumeRocket,
) -> RespondOrRedirect { ) -> RespondOrRedirect {
let conn = &*rockets.conn; let conn = &*rockets.conn;
@ -118,7 +118,7 @@ pub fn create(
} }
#[get("/logout")] #[get("/logout")]
pub fn delete(mut cookies: Cookies, intl: I18n) -> Flash<Redirect> { pub fn delete(mut cookies: Cookies<'_>, intl: I18n) -> Flash<Redirect> {
if let Some(cookie) = cookies.get_private(AUTH_COOKIE) { if let Some(cookie) = cookies.get_private(AUTH_COOKIE) {
cookies.remove_private(cookie); cookies.remove_private(cookie);
} }
@ -158,7 +158,7 @@ pub struct ResetForm {
#[post("/password-reset", data = "<form>")] #[post("/password-reset", data = "<form>")]
pub fn password_reset_request( pub fn password_reset_request(
mail: State<Arc<Mutex<Mailer>>>, mail: State<'_, Arc<Mutex<Mailer>>>,
form: Form<ResetForm>, form: Form<ResetForm>,
rockets: PlumeRocket, rockets: PlumeRocket,
) -> Ructe { ) -> Ructe {

View file

@ -1,6 +1,6 @@
use crate::routes::{errors::ErrorPage, Page};
use crate::template_utils::{IntoContext, Ructe};
use plume_models::{posts::Post, PlumeRocket}; use plume_models::{posts::Post, PlumeRocket};
use routes::{errors::ErrorPage, Page};
use template_utils::{IntoContext, Ructe};
#[get("/tag/<name>?<page>")] #[get("/tag/<name>?<page>")]
pub fn tag(name: String, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> { pub fn tag(name: String, page: Option<Page>, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {

View file

@ -1,10 +1,10 @@
#![allow(dead_code)] #![allow(dead_code)]
use crate::routes::Page;
use crate::template_utils::IntoContext;
use crate::{routes::errors::ErrorPage, template_utils::Ructe}; use crate::{routes::errors::ErrorPage, template_utils::Ructe};
use plume_models::{timeline::*, PlumeRocket}; use plume_models::{timeline::*, PlumeRocket};
use rocket::response::Redirect; use rocket::response::Redirect;
use routes::Page;
use template_utils::IntoContext;
#[get("/timeline/<id>?<page>")] #[get("/timeline/<id>?<page>")]
pub fn details(id: i32, rockets: PlumeRocket, page: Option<Page>) -> Result<Ructe, ErrorPage> { pub fn details(id: i32, rockets: PlumeRocket, page: Option<Page>) -> Result<Ructe, ErrorPage> {

View file

@ -14,7 +14,9 @@ use serde_json;
use std::{borrow::Cow, collections::HashMap}; use std::{borrow::Cow, collections::HashMap};
use validator::{Validate, ValidationError, ValidationErrors}; use validator::{Validate, ValidationError, ValidationErrors};
use inbox; use crate::inbox;
use crate::routes::{errors::ErrorPage, Page, RemoteForm, RespondOrRedirect};
use crate::template_utils::{IntoContext, Ructe};
use plume_common::activity_pub::{broadcast, inbox::FromId, ActivityStream, ApRequest, Id}; use plume_common::activity_pub::{broadcast, inbox::FromId, ActivityStream, ApRequest, Id};
use plume_common::utils; use plume_common::utils;
use plume_models::{ use plume_models::{
@ -31,8 +33,6 @@ use plume_models::{
users::*, users::*,
Error, PlumeRocket, Error, PlumeRocket,
}; };
use routes::{errors::ErrorPage, Page, RemoteForm, RespondOrRedirect};
use template_utils::{IntoContext, Ructe};
#[get("/me")] #[get("/me")]
pub fn me(user: Option<User>) -> RespondOrRedirect { pub fn me(user: Option<User>) -> RespondOrRedirect {
@ -413,7 +413,7 @@ pub fn update(
pub fn delete( pub fn delete(
name: String, name: String,
user: User, user: User,
mut cookies: Cookies, mut cookies: Cookies<'_>,
rockets: PlumeRocket, rockets: PlumeRocket,
) -> Result<Flash<Redirect>, ErrorPage> { ) -> Result<Flash<Redirect>, ErrorPage> {
let account = User::find_by_fqn(&rockets, &name)?; let account = User::find_by_fqn(&rockets, &name)?;
@ -580,7 +580,7 @@ pub fn outbox_page(
pub fn inbox( pub fn inbox(
name: String, name: String,
data: inbox::SignedJson<serde_json::Value>, data: inbox::SignedJson<serde_json::Value>,
headers: Headers, headers: Headers<'_>,
rockets: PlumeRocket, rockets: PlumeRocket,
) -> Result<String, status::BadRequest<&'static str>> { ) -> Result<String, status::BadRequest<&'static str>> {
User::find_by_fqn(&rockets, &name).map_err(|_| status::BadRequest(Some("User not found")))?; User::find_by_fqn(&rockets, &name).map_err(|_| status::BadRequest(Some("User not found")))?;

View file

@ -1,5 +1,6 @@
use plume_models::{notifications::*, users::User, Connection, PlumeRocket}; use plume_models::{notifications::*, users::User, Connection, PlumeRocket};
use crate::templates::Html;
use rocket::http::hyper::header::{ETag, EntityTag}; use rocket::http::hyper::header::{ETag, EntityTag};
use rocket::http::{Method, Status}; use rocket::http::{Method, Status};
use rocket::request::Request; use rocket::request::Request;
@ -7,7 +8,6 @@ use rocket::response::{self, content::Html as HtmlCt, Responder, Response};
use rocket_i18n::Catalog; use rocket_i18n::Catalog;
use std::collections::{btree_map::BTreeMap, hash_map::DefaultHasher}; use std::collections::{btree_map::BTreeMap, hash_map::DefaultHasher};
use std::hash::Hasher; use std::hash::Hasher;
use templates::Html;
pub use askama_escape::escape; pub use askama_escape::escape;
@ -53,7 +53,7 @@ impl IntoContext for PlumeRocket {
pub struct Ructe(pub Vec<u8>); pub struct Ructe(pub Vec<u8>);
impl<'r> Responder<'r> for Ructe { impl<'r> Responder<'r> for Ructe {
fn respond_to(self, r: &Request) -> response::Result<'r> { fn respond_to(self, r: &Request<'_>) -> response::Result<'r> {
//if method is not Get or page contain a form, no caching //if method is not Get or page contain a form, no caching
if r.method() != Method::Get || self.0.windows(6).any(|w| w == b"<form ") { if r.method() != Method::Get || self.0.windows(6).any(|w| w == b"<form ") {
return HtmlCt(self.0).respond_to(r); return HtmlCt(self.0).respond_to(r);
@ -82,7 +82,7 @@ impl<'r> Responder<'r> for Ructe {
macro_rules! render { macro_rules! render {
($group:tt :: $page:tt ( $( $param:expr ),* ) ) => { ($group:tt :: $page:tt ( $( $param:expr ),* ) ) => {
{ {
use templates; use crate::templates;
let mut res = vec![]; let mut res = vec![];
templates::$group::$page( templates::$group::$page(
@ -96,7 +96,7 @@ macro_rules! render {
} }
} }
pub fn translate_notification(ctx: BaseContext, notif: Notification) -> String { pub fn translate_notification(ctx: BaseContext<'_>, notif: Notification) -> String {
let name = notif.get_actor(ctx.0).unwrap().name(); let name = notif.get_actor(ctx.0).unwrap().name();
match notif.kind.as_ref() { match notif.kind.as_ref() {
notification_kind::COMMENT => i18n!(ctx.1, "{0} commented on your article."; &name), notification_kind::COMMENT => i18n!(ctx.1, "{0} commented on your article."; &name),

View file

@ -1,8 +1,9 @@
@use plume_models::CONFIG; @use plume_models::CONFIG;
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use template_utils::*;
@use routes::*;
@use std::path::Path; @use std::path::Path;
@use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, title: String, head: Content, header: Content, content: Content) @(ctx: BaseContext, title: String, head: Content, header: Content, content: Content)
<!DOCTYPE html> <!DOCTYPE html>

View file

@ -2,10 +2,10 @@
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use plume_models::users::User; @use plume_models::users::User;
@use templates::{base, partials::post_card};
@use template_utils::*;
@use routes::*;
@use std::path::Path; @use std::path::Path;
@use crate::templates::{base, partials::post_card};
@use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, blog: Blog, authors: &[User], page: i32, n_pages: i32, posts: Vec<Post>) @(ctx: BaseContext, blog: Blog, authors: &[User], page: i32, n_pages: i32, posts: Vec<Post>)

View file

@ -2,12 +2,12 @@
@use plume_models::blogs::Blog; @use plume_models::blogs::Blog;
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use plume_models::medias::Media; @use plume_models::medias::Media;
@use routes::blogs; @use crate::template_utils::*;
@use routes::blogs::EditForm; @use crate::templates::base;
@use routes::medias; @use crate::templates::partials::image_select;
@use template_utils::*; @use crate::routes::blogs;
@use templates::base; @use crate::routes::blogs::EditForm;
@use templates::partials::image_select; @use crate::routes::medias;
@(ctx: BaseContext, blog: &Blog, medias: Vec<Media>, form: &EditForm, errors: ValidationErrors) @(ctx: BaseContext, blog: &Blog, medias: Vec<Media>, form: &EditForm, errors: ValidationErrors)

View file

@ -1,8 +1,8 @@
@use validator::ValidationErrors; @use validator::ValidationErrors;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::blogs::NewBlogForm; @use crate::routes::blogs::NewBlogForm;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, form: &NewBlogForm, errors: ValidationErrors) @(ctx: BaseContext, form: &NewBlogForm, errors: ValidationErrors)

View file

@ -1,5 +1,5 @@
@use templates::base as base_template; @use crate::templates::base as base_template;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext, error_message: String, error: Content) @(ctx: BaseContext, error_message: String, error: Content)

View file

@ -1,5 +1,5 @@
@use templates::errors::base; @use crate::templates::errors::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext) @(ctx: BaseContext)

View file

@ -1,5 +1,5 @@
@use templates::errors::base; @use crate::templates::errors::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext, error_message: String) @(ctx: BaseContext, error_message: String)

View file

@ -1,5 +1,5 @@
@use templates::errors::base; @use crate::templates::errors::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext) @(ctx: BaseContext)
@ -7,4 +7,3 @@
<h1>@i18n!(ctx.1, "We couldn't find this page.")</h1> <h1>@i18n!(ctx.1, "We couldn't find this page.")</h1>
<p>@i18n!(ctx.1, "The link that led you here may be broken.")</p> <p>@i18n!(ctx.1, "The link that led you here may be broken.")</p>
}) })

View file

@ -1,5 +1,5 @@
@use templates::errors::base; @use crate::templates::errors::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext) @(ctx: BaseContext)

View file

@ -1,5 +1,5 @@
@use templates::errors::base; @use crate::templates::errors::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext) @(ctx: BaseContext)
@ -7,4 +7,3 @@
<h1>@i18n!(ctx.1, "The content you sent can't be processed.")</h1> <h1>@i18n!(ctx.1, "The content you sent can't be processed.")</h1>
<p>@i18n!(ctx.1, "Maybe it was too long.")</p> <p>@i18n!(ctx.1, "Maybe it was too long.")</p>
}) })

View file

@ -1,7 +1,7 @@
@use plume_models::{instance::Instance, users::User}; @use plume_models::{instance::Instance, users::User};
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, instance: Instance, admin: User, n_users: i64, n_articles: i64, n_instances: i64) @(ctx: BaseContext, instance: Instance, admin: User, n_users: i64, n_articles: i64, n_instances: i64)

View file

@ -1,9 +1,9 @@
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use validator::ValidationErrors; @use validator::ValidationErrors;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::instance::InstanceSettingsForm; @use crate::routes::instance::InstanceSettingsForm;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, instance: Instance, form: InstanceSettingsForm, errors: ValidationErrors) @(ctx: BaseContext, instance: Instance, form: InstanceSettingsForm, errors: ValidationErrors)

View file

@ -1,6 +1,6 @@
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext) @(ctx: BaseContext)

View file

@ -1,7 +1,7 @@
@use templates::base;
@use plume_models::blocklisted_emails::BlocklistedEmail; @use plume_models::blocklisted_emails::BlocklistedEmail;
@use template_utils::*; @use crate::templates::base;
@use routes::*; @use crate::template_utils::*;
@use crate::routes::*;
@(ctx:BaseContext, emails: Vec<BlocklistedEmail>, page:i32, n_pages:i32) @(ctx:BaseContext, emails: Vec<BlocklistedEmail>, page:i32, n_pages:i32)
@:base(ctx, i18n!(ctx.1, "Blocklisted Emails"), {}, {}, { @:base(ctx, i18n!(ctx.1, "Blocklisted Emails"), {}, {}, {

View file

@ -1,9 +1,9 @@
@use templates::{base, partials::*};
@use template_utils::*;
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use plume_models::timeline::Timeline; @use plume_models::timeline::Timeline;
@use routes::*; @use crate::templates::{base, partials::*};
@use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64, all_tl: Vec<(Timeline, Vec<Post>)>) @(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64, all_tl: Vec<(Timeline, Vec<Post>)>)

View file

@ -1,7 +1,7 @@
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, instance: Instance, instances: Vec<Instance>, page: i32, n_pages: i32) @(ctx: BaseContext, instance: Instance, instances: Vec<Instance>, page: i32, n_pages: i32)

View file

@ -1,5 +1,5 @@
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext) @(ctx: BaseContext)

View file

@ -1,7 +1,7 @@
@use plume_models::users::User; @use plume_models::users::User;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, users: Vec<User>, page: i32, n_pages: i32) @(ctx: BaseContext, users: Vec<User>, page: i32, n_pages: i32)

View file

@ -1,8 +1,8 @@
@use plume_models::medias::{Media, MediaCategory}; @use plume_models::medias::{Media, MediaCategory};
@use plume_models::safe_string::SafeString; @use plume_models::safe_string::SafeString;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, media: Media) @(ctx: BaseContext, media: Media)

View file

@ -1,7 +1,7 @@
@use plume_models::medias::*; @use plume_models::medias::*;
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, medias: Vec<Media>, page: i32, n_pages: i32) @(ctx: BaseContext, medias: Vec<Media>, page: i32, n_pages: i32)

View file

@ -1,6 +1,6 @@
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext) @(ctx: BaseContext)

View file

@ -1,6 +1,6 @@
@use templates::base;
@use template_utils::*;
@use plume_models::notifications::Notification; @use plume_models::notifications::Notification;
@use crate::templates::base;
@use crate::template_utils::*;
@(ctx: BaseContext, notifications: Vec<Notification>, page: i32, n_pages: i32) @(ctx: BaseContext, notifications: Vec<Notification>, page: i32, n_pages: i32)

View file

@ -1,6 +1,6 @@
@use template_utils::*;
@use plume_models::comments::CommentTree; @use plume_models::comments::CommentTree;
@use routes::*; @use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, comment_tree: &CommentTree, in_reply_to: Option<&str>, blog: &str, slug: &str) @(ctx: BaseContext, comment_tree: &CommentTree, in_reply_to: Option<&str>, blog: &str, slug: &str)

View file

@ -1,5 +1,5 @@
@use template_utils::*;
@use plume_models::medias::*; @use plume_models::medias::*;
@use crate::template_utils::*;
@(ctx: BaseContext, id: &str, title: String, optional: bool, medias: Vec<Media>, selected: Option<i32>) @(ctx: BaseContext, id: &str, title: String, optional: bool, medias: Vec<Media>, selected: Option<i32>)

View file

@ -1,6 +1,6 @@
@use template_utils::*;
@use plume_models::instance::Instance; @use plume_models::instance::Instance;
@use routes::*; @use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64) @(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64)

View file

@ -1,6 +1,6 @@
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use template_utils::*; @use crate::template_utils::*;
@use routes::*; @use crate::routes::*;
@(ctx: BaseContext, article: Post) @(ctx: BaseContext, article: Post)
@ -31,4 +31,3 @@
} }
</footer> </footer>
</div> </div>

View file

@ -1,14 +1,14 @@
@use templates::{base, partials::comment};
@use template_utils::*;
@use plume_models::blogs::Blog; @use plume_models::blogs::Blog;
@use plume_models::comments::{Comment, CommentTree}; @use plume_models::comments::{Comment, CommentTree};
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use plume_models::tags::Tag; @use plume_models::tags::Tag;
@use plume_models::users::User; @use plume_models::users::User;
@use validator::ValidationErrors;
@use routes::comments::NewCommentForm;
@use routes::*;
@use std::path::Path; @use std::path::Path;
@use validator::ValidationErrors;
@use crate::templates::{base, partials::comment};
@use crate::template_utils::*;
@use crate::routes::comments::NewCommentForm;
@use crate::routes::*;
@(ctx: BaseContext, article: Post, blog: Blog, comment_form: &NewCommentForm, comment_errors: ValidationErrors, tags: Vec<Tag>, comments: Vec<CommentTree>, previous_comment: Option<Comment>, n_likes: i64, n_reshares: i64, has_liked: bool, has_reshared: bool, is_following: bool, author: User) @(ctx: BaseContext, article: Post, blog: Blog, comment_form: &NewCommentForm, comment_errors: ValidationErrors, tags: Vec<Tag>, comments: Vec<CommentTree>, previous_comment: Option<Comment>, n_likes: i64, n_reshares: i64, has_liked: bool, has_reshared: bool, is_following: bool, author: User)

View file

@ -1,13 +1,13 @@
@use templates::base;
@use templates::partials::image_select;
@use template_utils::*;
@use validator::{ValidationErrors, ValidationErrorsKind};
@use std::borrow::Cow;
@use plume_models::medias::*; @use plume_models::medias::*;
@use plume_models::blogs::Blog; @use plume_models::blogs::Blog;
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use routes::posts::NewPostForm; @use std::borrow::Cow;
@use routes::*; @use validator::{ValidationErrors, ValidationErrorsKind};
@use crate::templates::base;
@use crate::templates::partials::image_select;
@use crate::template_utils::*;
@use crate::routes::posts::NewPostForm;
@use crate::routes::*;
@(ctx: BaseContext, title: String, blog: Blog, editing: bool, form: &NewPostForm, is_draft: bool, article: Option<Post>, errors: ValidationErrors, medias: Vec<Media>, content_len: u64) @(ctx: BaseContext, title: String, blog: Blog, editing: bool, form: &NewPostForm, is_draft: bool, article: Option<Post>, errors: ValidationErrors, medias: Vec<Media>, content_len: u64)

View file

@ -1,10 +1,10 @@
@use templates::remote_interact_base;
@use templates::partials::post_card;
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use routes::RemoteForm;
@use routes::session::LoginForm;
@use template_utils::*;
@use validator::ValidationErrors; @use validator::ValidationErrors;
@use crate::templates::remote_interact_base;
@use crate::templates::partials::post_card;
@use crate::template_utils::*;
@use crate::routes::RemoteForm;
@use crate::routes::session::LoginForm;
@(ctx: BaseContext, post: Post, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors) @(ctx: BaseContext, post: Post, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors)

View file

@ -1,8 +1,8 @@
@use templates::base;
@use routes::session::LoginForm;
@use routes::RemoteForm;
@use template_utils::*;
@use validator::ValidationErrors; @use validator::ValidationErrors;
@use crate::templates::base;
@use crate::template_utils::*;
@use crate::routes::session::LoginForm;
@use crate::routes::RemoteForm;
@(ctx: BaseContext, title: String, login_msg: String, remote_msg: String, header: Content, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors) @(ctx: BaseContext, title: String, login_msg: String, remote_msg: String, header: Content, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors)

View file

@ -1,5 +1,5 @@
@use templates::base; @use crate::templates::base;
@use template_utils::*; @use crate::template_utils::*;
@(ctx: BaseContext, now: &str) @(ctx: BaseContext, now: &str)

View file

@ -1,6 +1,6 @@
@use templates::{base, partials::post_card};
@use template_utils::*;
@use plume_models::posts::Post; @use plume_models::posts::Post;
@use crate::templates::{base, partials::post_card};
@use crate::template_utils::*;
@(ctx: BaseContext, query_str: &str, articles: Vec<Post>, page: i32, n_pages: i32) @(ctx: BaseContext, query_str: &str, articles: Vec<Post>, page: i32, n_pages: i32)

Some files were not shown because too many files have changed in this diff Show more