lemmynsfw-changes
Felix Ableitner 2024-01-25 15:09:35 +01:00
parent 4ad94551b0
commit 87954f0c98
2 changed files with 25 additions and 7 deletions

View File

@ -21,3 +21,4 @@ lemmy_db_schema = { workspace = true }
lemmy_db_views = { workspace = true, features = ["full"] }
lemmy_utils = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }

View File

@ -16,17 +16,16 @@ use lemmy_db_schema::{
community::{Community, CommunityInsertForm},
instance::Instance,
person::{Person, PersonInsertForm},
site::Site,
},
traits::Crud,
utils::{build_db_pool, get_conn, now},
SortType,
};
use lemmy_db_views::{
post_view::PostQuery,
structs::{PaginationCursor, SiteView},
};
use lemmy_db_views::{post_view::PostQuery, structs::PaginationCursor};
use lemmy_utils::error::{LemmyErrorExt2, LemmyResult};
use std::num::NonZeroU32;
use url::Url;
#[derive(Parser, Debug)]
struct CmdArgs {
@ -148,8 +147,6 @@ async fn try_main() -> LemmyResult<()> {
page_after.is_some()
);
let site = SiteView::read_local(&mut (&build_db_pool().await?).into()).await?;
// TODO: include local_user
let post_views = PostQuery {
community_id: community_ids.as_slice().first().cloned(),
@ -158,7 +155,7 @@ async fn try_main() -> LemmyResult<()> {
page_after,
..Default::default()
}
.list(&site.site, &mut conn.into())
.list(&site()?, &mut conn.into())
.await?;
if let Some(post_view) = post_views.into_iter().last() {
@ -182,3 +179,23 @@ async fn try_main() -> LemmyResult<()> {
Ok(())
}
fn site() -> LemmyResult<Site> {
Ok(Site {
id: Default::default(),
name: "".to_string(),
sidebar: None,
published: Default::default(),
updated: None,
icon: None,
banner: None,
description: None,
actor_id: Url::parse("http://example.com")?.into(),
last_refreshed_at: Default::default(),
inbox_url: Url::parse("http://example.com")?.into(),
private_key: None,
public_key: "".to_string(),
instance_id: Default::default(),
content_warning: None,
})
}