Remaining Fixes

This commit is contained in:
Neshura 2025-06-27 23:24:44 +02:00
parent 857c5040c3
commit 42f46b33fd
Signed by: Neshura
GPG key ID: 4E2D47B1374C297D
5 changed files with 22 additions and 37 deletions

View file

@ -79,7 +79,7 @@ impl Bot {
}
pub(crate) async fn run(&mut self) {
loop {
let mut lemmy = match Piefed::new(&self.shared_config).await {
let mut piefed = match Piefed::new(&self.shared_config).await {
Ok(data) => data,
Err(_) => {
sleep(Duration::seconds(10).to_std().unwrap()).await;
@ -87,7 +87,7 @@ impl Bot {
},
};
lemmy.get_communities().await;
piefed.get_communities().await;
self.history = SeriesHistory::load_history();
@ -97,7 +97,7 @@ impl Bot {
self.ping_status().await;
let read_copy = self.shared_config.read().expect("Read Lock Failed").clone();
for series in read_copy.series {
series.update(&mut self.history, &lemmy, &self.shared_config).await;
series.update(&mut self.history, &piefed, &self.shared_config).await;
debug!("Done Updating Series");
self.wait(1, Wait::Absolute).await;
}
@ -109,7 +109,7 @@ impl Bot {
self.wait(30, Wait::Absolute).await;
}
lemmy.logout().await;
piefed.logout().await;
}
}

View file

@ -257,7 +257,6 @@ pub(crate) struct PostConfig {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub(crate) struct PinConfig {
pub(crate) pin_new_post_local: bool,
pub(crate) pin_new_post_community: bool,
}

View file

@ -237,7 +237,7 @@ impl Piefed {
match response.status() {
StatusCode::OK => {
let data: LoginResponse = response
.json()
.json::<LoginResponse>()
.await
.expect("Successful Login Request should return JSON");
match data.jwt {
@ -334,29 +334,6 @@ impl Piefed {
.collect())
}
pub(crate) async fn get_local_pinned(&self) -> Option<Vec<PostView>> {
let list_params = GetPosts {
type_: Some(ListingType::Local),
..Default::default()
};
let response: String = match self.get_data_query("/api/alpha/post/list", &list_params).await {
Some(data) => data,
None => return None,
};
let json_data: GetPostsResponse = match self.parse_json(&response).await {
Some(data) => data,
None => return None,
};
Some(json_data
.posts
.iter()
.filter(|post| post.post.sticky)
.cloned()
.collect())
}
pub(crate) async fn get_communities(&mut self) {
let list_params = ListCommunitiesParams {
type_: Some(ListingType::Local),

View file

@ -1,7 +1,17 @@
use serde_derive::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use crate::piefed_api::post::{Counts, ListingType, SortType};
use crate::piefed_api::types::{CommunityId, SubscribedType};
use crate::piefed_api::post::{ListingType, SortType};
use crate::piefed_api::types::{CommunityId, PostId, SubscribedType};
#[skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct CommunityCounts {
pub id: CommunityId,
pub post_count: i32,
pub post_reply_count: i32,
pub subscriptions_count: i32,
pub published: String,
}
#[skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
@ -46,8 +56,8 @@ pub struct ListCommunitiesResponse {
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct CommunityView {
pub community: Community,
pub subscribed_type: SubscribedType,
pub subscribed: SubscribedType,
pub blocked: bool,
pub counts: Counts,
pub counts: CommunityCounts,
pub activity_alert: bool
}

View file

@ -115,20 +115,19 @@ pub struct PostView {
pub banned_from_community: bool,
pub creator_is_moderator: bool,
pub creator_is_admin: bool,
pub counts: Counts,
pub counts: PostCounts,
pub subscribed: SubscribedType,
pub saved: bool,
pub activity_alert: bool,
pub read: bool,
pub hidden: bool,
pub creator_blocked: bool,
pub my_vote: i32,
pub unread_comments: i32,
}
#[skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct Counts {
pub struct PostCounts {
pub post_id: PostId,
pub comments: i32,
pub score: i32,
@ -150,7 +149,7 @@ pub struct Post {
pub removed: bool,
pub locked: bool,
pub published: String,
pub updated: String,
pub updated: Option<String>,
pub deleted: bool,
pub nsfw: bool,
pub thumbnail_url: Option<String>,