Remove dead code

This commit is contained in:
Felix Ableitner 2020-08-11 15:36:17 +02:00
parent 8c9928bcdf
commit 714b5173d5
10 changed files with 4 additions and 95 deletions

View File

@ -196,15 +196,6 @@ impl Likeable<CommentLikeForm> for CommentLike {
}
}
impl CommentLike {
pub fn from_post(conn: &PgConnection, post_id_from: i32) -> Result<Vec<Self>, Error> {
use crate::schema::comment_like::dsl::*;
comment_like
.filter(post_id.eq(post_id_from))
.load::<Self>(conn)
}
}
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
#[belongs_to(Comment)]
#[table_name = "comment_saved"]

View File

@ -99,11 +99,6 @@ impl Community {
.first::<Self>(conn)
}
pub fn list_local(conn: &PgConnection) -> Result<Vec<Self>, Error> {
use crate::schema::community::dsl::*;
community.filter(local.eq(true)).load::<Community>(conn)
}
pub fn update_deleted(
conn: &PgConnection,
community_id: i32,

View File

@ -386,20 +386,6 @@ pub struct CommunityUserBanView {
}
impl CommunityUserBanView {
pub fn for_community(conn: &PgConnection, from_community_id: i32) -> Result<Vec<Self>, Error> {
use super::community_view::community_user_ban_view::dsl::*;
community_user_ban_view
.filter(community_id.eq(from_community_id))
.load::<Self>(conn)
}
pub fn for_user(conn: &PgConnection, from_user_id: i32) -> Result<Vec<Self>, Error> {
use super::community_view::community_user_ban_view::dsl::*;
community_user_ban_view
.filter(user_id.eq(from_user_id))
.load::<Self>(conn)
}
pub fn get(
conn: &PgConnection,
from_user_id: i32,

View File

@ -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<T: MaybeOptional<i64>>(mut self, page: T) -> Self {
self.page = page.get_optional();
self

View File

@ -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<Utc> {
DateTime::<Utc>::from_utc(ndt, Utc)
}
pub fn naive_from_unix(time: i64) -> NaiveDateTime {
NaiveDateTime::from_timestamp(time, 0)
}

View File

@ -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())
}

View File

@ -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<User_, Error> {
let claims: Claims = Claims::decode(&jwt).expect("Invalid token").claims;
User_::read(&conn, claims.id)
}
}

View File

@ -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<NodeInfo, LemmyError> {
let well_known_uri = Url::parse(&format!(
"{}://{}/.well-known/nodeinfo",
get_apub_protocol_string(),
domain
))?;
let well_known = fetch_remote_object::<NodeInfoWellKnown>(client, &well_known_uri).await?;
let nodeinfo = fetch_remote_object::<NodeInfo>(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<Response>(
@ -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<Vec<Post>, LemmyError> {
// let outbox_url = Url::parse(&community.get_outbox_url())?;
// let outbox = fetch_remote_object::<OrderedCollection>(&outbox_url)?;
// let items = outbox.collection_props.get_many_items_base_boxes();
// Ok(
// items
// .context(location_info!())?
// .map(|obox: &BaseBox| -> Result<PostForm, LemmyError> {
// let page = obox.clone().to_concrete::<Page>()?;
// PostForm::from_page(&page, conn)
// })
// .map(|pf| upsert_post(&pf?, conn))
// .collect::<Result<Vec<Post>, LemmyError>>()?,
// )
// }

View File

@ -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<ConnectionManager<PgConnection>>;
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,

View File

@ -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<Pool<ConnectionManager<PgConnection>>>;
pub type RateLimitParam = web::Data<Arc<Mutex<RateLimiter>>>;
pub type ChatServerParam = web::Data<Addr<ChatServer>>;