2024-05-06 20:51:31 +02:00
|
|
|
use crate::{HTTP_CLIENT, lemmy};
|
2023-12-30 01:27:11 +01:00
|
|
|
use chrono::{DateTime, Duration, Utc};
|
|
|
|
use serde_derive::{Deserialize, Serialize};
|
2023-12-16 03:09:18 +01:00
|
|
|
use std::cmp::Ordering;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::ops::Sub;
|
2024-01-08 21:06:25 +01:00
|
|
|
use async_trait::async_trait;
|
2023-12-16 03:09:18 +01:00
|
|
|
use url::Url;
|
2024-01-08 21:06:25 +01:00
|
|
|
use crate::fetchers::Fetcher;
|
|
|
|
use crate::fetchers::jnovel::JPostInfo::{Chapter, Volume};
|
|
|
|
use crate::fetchers::jnovel::PartInfo::{NoParts, Part};
|
|
|
|
use crate::lemmy::{PostInfo, PostInfoInner};
|
2024-05-06 20:51:31 +02:00
|
|
|
use systemd_journal_logger::connected_to_journal;
|
|
|
|
|
|
|
|
macro_rules! error {
|
|
|
|
($msg:tt) => {
|
|
|
|
match connected_to_journal() {
|
|
|
|
true => log::error!("[ERROR] {}", $msg),
|
|
|
|
false => eprintln!("[ERROR] {}", $msg),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-05-06 20:55:30 +02:00
|
|
|
macro_rules! info {
|
|
|
|
($msg:tt) => {
|
|
|
|
match connected_to_journal() {
|
|
|
|
true => log::info!("[INFO] {}", $msg),
|
|
|
|
false => println!("[INFO] {}", $msg),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-12-17 22:33:57 +01:00
|
|
|
static PAST_DAYS_ELIGIBLE: u8 = 4;
|
2023-12-16 03:09:18 +01:00
|
|
|
|
|
|
|
macro_rules! api_url {
|
|
|
|
() => {
|
2023-12-29 14:34:33 +01:00
|
|
|
"https://labs.j-novel.club/app/v1".to_owned()
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! jnc_base_url {
|
|
|
|
() => {
|
2023-12-29 14:34:33 +01:00
|
|
|
"https://j-novel.club".to_owned()
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
struct VolumesWrapper {
|
|
|
|
volumes: Vec<VolumeDetail>,
|
|
|
|
pagination: PaginationInfo,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
struct ChapterWrapper {
|
|
|
|
parts: Vec<ChapterDetail>,
|
|
|
|
pagination: PaginationInfo,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
struct PaginationInfo {
|
|
|
|
limit: usize,
|
|
|
|
skip: usize,
|
|
|
|
#[serde(alias = "lastPage")]
|
|
|
|
last_page: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
pub(crate) struct Cover {
|
|
|
|
#[serde(alias = "coverUrl")]
|
|
|
|
pub(crate) cover: String,
|
|
|
|
#[serde(alias = "thumbnailUrl")]
|
|
|
|
pub(crate) thumbnail: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
pub(crate) struct VolumeDetail {
|
|
|
|
pub(crate) title: String,
|
|
|
|
pub(crate) slug: String,
|
2024-01-08 21:06:25 +01:00
|
|
|
number: u8,
|
|
|
|
publishing: String,
|
2023-12-16 03:09:18 +01:00
|
|
|
#[serde(alias = "shortDescription")]
|
2024-01-08 21:06:25 +01:00
|
|
|
short_description: String,
|
|
|
|
cover: Cover,
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
|
|
|
pub(crate) struct ChapterDetail {
|
|
|
|
pub(crate) title: String,
|
|
|
|
pub(crate) slug: String,
|
2024-01-08 21:06:25 +01:00
|
|
|
launch: String,
|
2023-12-16 03:09:18 +01:00
|
|
|
pub(crate) cover: Option<Cover>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub(crate) enum PartInfo {
|
|
|
|
NoParts,
|
|
|
|
Part(u8),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartInfo {
|
2023-12-16 13:28:38 +01:00
|
|
|
pub(crate) fn as_u8(&self) -> u8 {
|
|
|
|
match self {
|
|
|
|
Part(number) => *number,
|
|
|
|
NoParts => 0,
|
|
|
|
}
|
|
|
|
}
|
2023-12-17 14:42:00 +01:00
|
|
|
|
|
|
|
pub(crate) fn as_string(&self) -> String {
|
|
|
|
self.as_u8().to_string()
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq for PartInfo {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
2023-12-16 13:28:38 +01:00
|
|
|
let self_numeric = self.as_u8();
|
|
|
|
let other_numeric = other.as_u8();
|
2023-12-16 03:09:18 +01:00
|
|
|
self_numeric == other_numeric
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for PartInfo {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
2023-12-30 01:27:11 +01:00
|
|
|
if self.gt(other) {
|
|
|
|
Some(Ordering::Greater)
|
|
|
|
} else if self.eq(other) {
|
|
|
|
Some(Ordering::Equal)
|
|
|
|
} else {
|
|
|
|
Some(Ordering::Less)
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn lt(&self, other: &Self) -> bool {
|
2023-12-16 13:28:38 +01:00
|
|
|
let self_numeric = self.as_u8();
|
|
|
|
let other_numeric = other.as_u8();
|
2023-12-16 03:09:18 +01:00
|
|
|
|
|
|
|
self_numeric < other_numeric
|
|
|
|
}
|
|
|
|
|
|
|
|
fn le(&self, other: &Self) -> bool {
|
|
|
|
!self.gt(other)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn gt(&self, other: &Self) -> bool {
|
2023-12-16 13:28:38 +01:00
|
|
|
let self_numeric = self.as_u8();
|
|
|
|
let other_numeric = other.as_u8();
|
2023-12-16 03:09:18 +01:00
|
|
|
|
|
|
|
self_numeric > other_numeric
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ge(&self, other: &Self) -> bool {
|
|
|
|
!self.lt(other)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2024-01-08 21:06:25 +01:00
|
|
|
pub(crate) enum JPostInfo {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter {
|
|
|
|
part: PartInfo,
|
2024-01-08 21:06:25 +01:00
|
|
|
lemmy_info: PostInfoInner,
|
2023-12-30 01:27:11 +01:00
|
|
|
},
|
|
|
|
Volume {
|
|
|
|
part: PartInfo,
|
|
|
|
description: String,
|
2024-01-08 21:06:25 +01:00
|
|
|
lemmy_info: PostInfoInner,
|
2023-12-30 01:27:11 +01:00
|
|
|
},
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
impl JPostInfo {
|
2023-12-17 14:42:00 +01:00
|
|
|
pub(crate) fn get_part_info(&self) -> PartInfo {
|
|
|
|
match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter {
|
|
|
|
part: part_info, ..
|
|
|
|
} => *part_info,
|
|
|
|
Volume {
|
|
|
|
part: part_info, ..
|
|
|
|
} => *part_info,
|
2023-12-17 14:42:00 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-08 21:06:25 +01:00
|
|
|
}
|
2023-12-17 14:42:00 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
impl PostInfo for JPostInfo {
|
|
|
|
fn get_info(&self) -> PostInfoInner {
|
2023-12-17 14:42:00 +01:00
|
|
|
match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { lemmy_info, .. } => lemmy_info.clone(),
|
|
|
|
Volume { lemmy_info, .. } => lemmy_info.clone(),
|
2023-12-17 14:42:00 +01:00
|
|
|
}
|
|
|
|
}
|
2023-12-17 14:42:22 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
fn get_description(&self) -> Option<String> {
|
2023-12-17 14:42:22 +01:00
|
|
|
match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { .. } => None,
|
|
|
|
Volume { description, .. } => Some(description.clone()),
|
2023-12-17 14:42:22 +01:00
|
|
|
}
|
|
|
|
}
|
2023-12-17 14:42:00 +01:00
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
impl PartialEq for JPostInfo {
|
2023-12-16 03:09:18 +01:00
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
let self_part = match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
let other_part = match other {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
self_part.eq(other_part)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
impl PartialOrd for JPostInfo {
|
2023-12-16 03:09:18 +01:00
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
2023-12-30 01:27:11 +01:00
|
|
|
if self.gt(other) {
|
|
|
|
Some(Ordering::Greater)
|
|
|
|
} else if self.eq(other) {
|
|
|
|
Some(Ordering::Equal)
|
|
|
|
} else {
|
|
|
|
Some(Ordering::Less)
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn lt(&self, other: &Self) -> bool {
|
|
|
|
let self_part = match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
let other_part = match other {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
self_part < other_part
|
|
|
|
}
|
|
|
|
|
|
|
|
fn le(&self, other: &Self) -> bool {
|
|
|
|
!self.gt(other)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn gt(&self, other: &Self) -> bool {
|
|
|
|
let self_part = match self {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
let other_part = match other {
|
2023-12-30 01:27:11 +01:00
|
|
|
Chapter { part, .. } => part,
|
|
|
|
Volume { part, .. } => part,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
self_part > other_part
|
|
|
|
}
|
|
|
|
|
|
|
|
fn ge(&self, other: &Self) -> bool {
|
|
|
|
!self.lt(other)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
pub(crate) struct JFetcherOptions {
|
|
|
|
series_slug: String,
|
|
|
|
series_has_parts: bool
|
|
|
|
}
|
|
|
|
|
|
|
|
impl JFetcherOptions {
|
|
|
|
pub(crate) fn new(series_slug: String, series_has_parts: bool) -> Self {
|
|
|
|
JFetcherOptions {
|
|
|
|
series_slug,
|
|
|
|
series_has_parts
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Fetcher for JFetcherOptions {
|
|
|
|
type Return = JPostInfo;
|
|
|
|
async fn check_feed(&self) -> Result<Vec<Self::Return>, ()> {
|
|
|
|
let response = match HTTP_CLIENT
|
|
|
|
.get(api_url!() + "/series/" + self.series_slug.as_str() + "/volumes?format=json")
|
|
|
|
.send()
|
|
|
|
.await
|
|
|
|
{
|
|
|
|
Ok(data) => match data.text().await {
|
|
|
|
Ok(data) => data,
|
|
|
|
Err(e) => {
|
2024-05-06 22:54:01 +02:00
|
|
|
let err_msg = format!("While checking feed: {e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2024-01-08 21:06:25 +01:00
|
|
|
return Err(());
|
|
|
|
}
|
|
|
|
},
|
2023-12-30 01:27:11 +01:00
|
|
|
Err(e) => {
|
|
|
|
let err_msg = format!("{e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2023-12-30 01:27:11 +01:00
|
|
|
return Err(());
|
2023-12-17 22:29:18 +01:00
|
|
|
}
|
2024-01-08 21:06:25 +01:00
|
|
|
};
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let mut volume_brief_data: VolumesWrapper = match serde_json::from_str(&response) {
|
|
|
|
Ok(data) => data,
|
|
|
|
Err(e) => {
|
|
|
|
let err_msg = format!("{e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2024-01-08 21:06:25 +01:00
|
|
|
return Err(());
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
2024-01-08 21:06:25 +01:00
|
|
|
};
|
|
|
|
volume_brief_data.volumes.reverse(); // Makes breaking out of the volume loop easier
|
|
|
|
|
|
|
|
// If no parts just use 0 as Part indicator as no Series with Parts has a Part 0
|
|
|
|
let mut volume_map: HashMap<u8, JPostInfo> = HashMap::new();
|
|
|
|
let mut prepub_map: HashMap<u8, JPostInfo> = HashMap::new();
|
|
|
|
|
|
|
|
for volume in volume_brief_data.volumes.iter() {
|
|
|
|
let publishing_date = DateTime::parse_from_rfc3339(&volume.publishing).unwrap();
|
|
|
|
if publishing_date < Utc::now().sub(Duration::days(PAST_DAYS_ELIGIBLE as i64)) {
|
|
|
|
match self.series_has_parts {
|
|
|
|
true => continue,
|
|
|
|
false => break,
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-08 21:06:25 +01:00
|
|
|
let new_part_info: PartInfo;
|
|
|
|
|
|
|
|
if self.series_has_parts {
|
|
|
|
let mut part_number: Option<u8> = None;
|
|
|
|
let splits: Vec<&str> = volume.slug.split('-').collect();
|
|
|
|
for (index, split) in splits.clone().into_iter().enumerate() {
|
|
|
|
if split == "part" {
|
|
|
|
part_number = Some(
|
|
|
|
splits[index + 1]
|
|
|
|
.parse::<u8>()
|
|
|
|
.expect("Split Element after 'Part' should always be a number"),
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
match part_number {
|
|
|
|
Some(number) => new_part_info = Part(number),
|
|
|
|
None => {
|
2024-05-06 20:55:30 +02:00
|
|
|
info!("No Part found, assuming 1");
|
2024-01-08 21:06:25 +01:00
|
|
|
new_part_info = Part(1);
|
|
|
|
}
|
2023-12-30 01:27:11 +01:00
|
|
|
}
|
2024-01-08 21:06:25 +01:00
|
|
|
} else {
|
|
|
|
new_part_info = NoParts;
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let post_url = format!(
|
|
|
|
"{}/series/{}#volume-{}",
|
|
|
|
jnc_base_url!(),
|
|
|
|
self.series_slug.as_str(),
|
|
|
|
volume.number
|
|
|
|
);
|
|
|
|
let post_details = lemmy::PostInfoInner {
|
|
|
|
title: volume.title.clone(),
|
|
|
|
url: Url::parse(&post_url).unwrap(),
|
|
|
|
};
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let new_post_info = Volume {
|
2023-12-16 03:09:18 +01:00
|
|
|
part: new_part_info,
|
2024-01-08 21:06:25 +01:00
|
|
|
description: volume.short_description.clone(),
|
|
|
|
lemmy_info: post_details,
|
2023-12-16 03:09:18 +01:00
|
|
|
};
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let part_id = new_part_info.as_u8();
|
|
|
|
|
|
|
|
if publishing_date <= Utc::now() {
|
|
|
|
volume_map
|
|
|
|
.entry(part_id)
|
|
|
|
.and_modify(|val| {
|
|
|
|
if *val < new_post_info {
|
|
|
|
*val = new_post_info.clone()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.or_insert(new_post_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(prepub_info) = get_latest_prepub(&volume.slug).await? {
|
|
|
|
let prepub_post_info = Chapter {
|
|
|
|
part: new_part_info,
|
|
|
|
lemmy_info: prepub_info,
|
|
|
|
};
|
|
|
|
|
|
|
|
prepub_map
|
|
|
|
.entry(part_id)
|
|
|
|
.and_modify(|val| {
|
|
|
|
if *val < prepub_post_info {
|
|
|
|
*val = prepub_post_info.clone()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.or_insert(prepub_post_info);
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let mut result_vec: Vec<JPostInfo> = volume_map.values().cloned().collect();
|
|
|
|
let mut prepub_vec: Vec<JPostInfo> = prepub_map.values().cloned().collect();
|
|
|
|
result_vec.append(&mut prepub_vec);
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
Ok(result_vec)
|
|
|
|
}
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
|
|
|
|
async fn get_latest_prepub(volume_slug: &str) -> Result<Option<lemmy::PostInfoInner>, ()> {
|
2023-12-17 22:29:18 +01:00
|
|
|
let response = match HTTP_CLIENT
|
2023-12-16 03:09:18 +01:00
|
|
|
.get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json")
|
|
|
|
.send()
|
2023-12-30 01:27:11 +01:00
|
|
|
.await
|
|
|
|
{
|
|
|
|
Ok(data) => match data.text().await {
|
|
|
|
Ok(data) => data,
|
|
|
|
Err(e) => {
|
2024-05-06 22:54:01 +02:00
|
|
|
let err_msg = format!("While getting latest PrePub: {e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2023-12-30 01:27:11 +01:00
|
|
|
return Err(());
|
2023-12-17 22:29:18 +01:00
|
|
|
}
|
|
|
|
},
|
2023-12-30 00:24:45 +01:00
|
|
|
Err(e) => {
|
|
|
|
let err_msg = format!("{e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2023-12-30 01:27:11 +01:00
|
|
|
return Err(());
|
2023-12-30 00:24:45 +01:00
|
|
|
}
|
2023-12-17 22:29:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
let mut volume_prepub_parts_data: ChapterWrapper = match serde_json::from_str(&response) {
|
|
|
|
Ok(data) => data,
|
2023-12-30 00:24:45 +01:00
|
|
|
Err(e) => {
|
|
|
|
let err_msg = format!("{e}");
|
2024-05-06 20:51:31 +02:00
|
|
|
error!(err_msg);
|
2023-12-30 01:27:11 +01:00
|
|
|
return Err(());
|
2023-12-30 00:24:45 +01:00
|
|
|
}
|
2023-12-17 22:29:18 +01:00
|
|
|
};
|
2023-12-16 13:44:37 +01:00
|
|
|
volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2024-01-08 21:06:25 +01:00
|
|
|
let mut post_details: Option<lemmy::PostInfoInner> = None;
|
2023-12-16 03:09:18 +01:00
|
|
|
|
2023-12-16 13:44:37 +01:00
|
|
|
for prepub_part in volume_prepub_parts_data.parts.iter() {
|
|
|
|
let publishing_date = DateTime::parse_from_rfc3339(&prepub_part.launch).unwrap();
|
2023-12-16 03:09:18 +01:00
|
|
|
if publishing_date > Utc::now() {
|
2023-12-30 01:27:11 +01:00
|
|
|
break;
|
|
|
|
} else if publishing_date < Utc::now().sub(Duration::days(PAST_DAYS_ELIGIBLE as i64)) {
|
|
|
|
continue;
|
2023-12-16 03:09:18 +01:00
|
|
|
}
|
|
|
|
|
2023-12-16 13:44:37 +01:00
|
|
|
let post_url = format!("{}/read/{}", jnc_base_url!(), prepub_part.slug);
|
2024-01-08 21:06:25 +01:00
|
|
|
post_details = Some(lemmy::PostInfoInner {
|
2023-12-16 13:44:37 +01:00
|
|
|
title: prepub_part.title.clone(),
|
2023-12-16 03:09:18 +01:00
|
|
|
url: Url::parse(&post_url).unwrap(),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(post_details)
|
|
|
|
}
|