diff --git a/server/lemmy_db/src/comment.rs b/server/lemmy_db/src/comment.rs index 354922e8..fc70f78b 100644 --- a/server/lemmy_db/src/comment.rs +++ b/server/lemmy_db/src/comment.rs @@ -196,15 +196,6 @@ impl Likeable for CommentLike { } } -impl CommentLike { - pub fn from_post(conn: &PgConnection, post_id_from: i32) -> Result, Error> { - use crate::schema::comment_like::dsl::*; - comment_like - .filter(post_id.eq(post_id_from)) - .load::(conn) - } -} - #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)] #[belongs_to(Comment)] #[table_name = "comment_saved"] diff --git a/server/lemmy_db/src/community.rs b/server/lemmy_db/src/community.rs index b4200b2d..7490f366 100644 --- a/server/lemmy_db/src/community.rs +++ b/server/lemmy_db/src/community.rs @@ -99,11 +99,6 @@ impl Community { .first::(conn) } - pub fn list_local(conn: &PgConnection) -> Result, Error> { - use crate::schema::community::dsl::*; - community.filter(local.eq(true)).load::(conn) - } - pub fn update_deleted( conn: &PgConnection, community_id: i32, diff --git a/server/lemmy_db/src/community_view.rs b/server/lemmy_db/src/community_view.rs index 540841f2..e68dbd5e 100644 --- a/server/lemmy_db/src/community_view.rs +++ b/server/lemmy_db/src/community_view.rs @@ -386,20 +386,6 @@ pub struct CommunityUserBanView { } impl CommunityUserBanView { - pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result, Error> { - use super::community_view::community_user_ban_view::dsl::*; - community_user_ban_view - .filter(community_id.eq(from_community_id)) - .load::(conn) - } - - pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result, Error> { - use super::community_view::community_user_ban_view::dsl::*; - community_user_ban_view - .filter(user_id.eq(from_user_id)) - .load::(conn) - } - pub fn get( conn: &PgConnection, from_user_id: i32, diff --git a/server/lemmy_db/src/post_view.rs b/server/lemmy_db/src/post_view.rs index 9878807a..c10cdf1e 100644 --- a/server/lemmy_db/src/post_view.rs +++ b/server/lemmy_db/src/post_view.rs @@ -252,11 +252,6 @@ impl<'a> PostQueryBuilder<'a> { self } - pub fn unread_only(mut self, unread_only: bool) -> Self { - self.unread_only = unread_only; - self - } - pub fn page>(mut self, page: T) -> Self { self.page = page.get_optional(); self diff --git a/server/lemmy_utils/src/lib.rs b/server/lemmy_utils/src/lib.rs index fc50e199..16d954ff 100644 --- a/server/lemmy_utils/src/lib.rs +++ b/server/lemmy_utils/src/lib.rs @@ -12,7 +12,7 @@ pub extern crate url; pub mod settings; use crate::settings::Settings; -use chrono::{DateTime, FixedOffset, Local, NaiveDateTime, Utc}; +use chrono::{DateTime, FixedOffset, Local, NaiveDateTime}; use itertools::Itertools; use lettre::{ smtp::{ @@ -43,10 +43,6 @@ macro_rules! location_info { }; } -pub fn to_datetime_utc(ndt: NaiveDateTime) -> DateTime { - DateTime::::from_utc(ndt, Utc) -} - pub fn naive_from_unix(time: i64) -> NaiveDateTime { NaiveDateTime::from_timestamp(time, 0) } diff --git a/server/lemmy_utils/src/settings.rs b/server/lemmy_utils/src/settings.rs index 6a566de7..8e5da6ac 100644 --- a/server/lemmy_utils/src/settings.rs +++ b/server/lemmy_utils/src/settings.rs @@ -121,10 +121,6 @@ impl Settings { ) } - pub fn api_endpoint(&self) -> String { - format!("{}/api/v1", self.hostname) - } - pub fn get_config_defaults_location() -> String { env::var("LEMMY_CONFIG_LOCATION").unwrap_or_else(|_| CONFIG_FILE_DEFAULTS.to_string()) } diff --git a/server/src/api/claims.rs b/server/src/api/claims.rs index 477ff1d9..0f0d05de 100644 --- a/server/src/api/claims.rs +++ b/server/src/api/claims.rs @@ -1,6 +1,5 @@ -use diesel::{result::Error, PgConnection}; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation}; -use lemmy_db::{user::User_, Crud}; +use lemmy_db::user::User_; use lemmy_utils::settings::Settings; use serde::{Deserialize, Serialize}; @@ -37,9 +36,4 @@ impl Claims { ) .unwrap() } - - pub fn find_by_jwt(conn: &PgConnection, jwt: &str) -> Result { - let claims: Claims = Claims::decode(&jwt).expect("Invalid token").claims; - User_::read(&conn, claims.id) - } } diff --git a/server/src/apub/fetcher.rs b/server/src/apub/fetcher.rs index 55e0991b..f6573a1f 100644 --- a/server/src/apub/fetcher.rs +++ b/server/src/apub/fetcher.rs @@ -11,7 +11,6 @@ use crate::{ }, blocking, request::{retry, RecvError}, - routes::nodeinfo::{NodeInfo, NodeInfoWellKnown}, DbPool, LemmyError, }; @@ -43,20 +42,6 @@ use url::Url; static ACTOR_REFETCH_INTERVAL_SECONDS: i64 = 24 * 60 * 60; static ACTOR_REFETCH_INTERVAL_SECONDS_DEBUG: i64 = 10; -// Fetch nodeinfo metadata from a remote instance. -async fn _fetch_node_info(client: &Client, domain: &str) -> Result { - let well_known_uri = Url::parse(&format!( - "{}://{}/.well-known/nodeinfo", - get_apub_protocol_string(), - domain - ))?; - - let well_known = fetch_remote_object::(client, &well_known_uri).await?; - let nodeinfo = fetch_remote_object::(client, &well_known.links.href).await?; - - Ok(nodeinfo) -} - /// Fetch any type of ActivityPub object, handling things like HTTP headers, deserialisation, /// timeouts etc. pub async fn fetch_remote_object( @@ -447,26 +432,3 @@ pub async fn get_or_fetch_and_insert_comment( Err(e) => Err(e.into()), } } - -// TODO It should not be fetching data from a community outbox. -// All posts, comments, comment likes, etc should be posts to our community_inbox -// The only data we should be periodically fetching (if it hasn't been fetched in the last day -// maybe), is community and user actors -// and user actors -// Fetch all posts in the outbox of the given user, and insert them into the database. -// fn fetch_community_outbox(community: &Community, conn: &PgConnection) -> Result, LemmyError> { -// let outbox_url = Url::parse(&community.get_outbox_url())?; -// let outbox = fetch_remote_object::(&outbox_url)?; -// let items = outbox.collection_props.get_many_items_base_boxes(); - -// Ok( -// items -// .context(location_info!())? -// .map(|obox: &BaseBox| -> Result { -// let page = obox.clone().to_concrete::()?; -// PostForm::from_page(&page, conn) -// }) -// .map(|pf| upsert_post(&pf?, conn)) -// .collect::, LemmyError>>()?, -// ) -// } diff --git a/server/src/main.rs b/server/src/main.rs index b27ddb9c..daa41447 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,17 +1,13 @@ -extern crate lemmy_server; #[macro_use] extern crate diesel_migrations; #[macro_use] pub extern crate lazy_static; -pub type DbPool = Pool>; - -use crate::lemmy_server::actix_web::dev::Service; use actix::prelude::*; use actix_web::{ body::Body, client::Client, - dev::{ServiceRequest, ServiceResponse}, + dev::{Service, ServiceRequest, ServiceResponse}, http::{ header::{CACHE_CONTROL, CONTENT_TYPE}, HeaderValue, diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index 4a7d3099..c3987145 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -7,15 +7,13 @@ pub mod nodeinfo; pub mod webfinger; pub mod websocket; -use crate::{rate_limit::rate_limiter::RateLimiter, websocket::server::ChatServer}; +use crate::websocket::server::ChatServer; use actix::prelude::*; use actix_web::*; use diesel::{ r2d2::{ConnectionManager, Pool}, PgConnection, }; -use std::sync::{Arc, Mutex}; pub type DbPoolParam = web::Data>>; -pub type RateLimitParam = web::Data>>; pub type ChatServerParam = web::Data>;