2024-05-12 00:11:28 +02:00
|
|
|
|
|
|
|
#[serde_inline_default::serde_inline_default]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, serde_default::DefaultFromSerde)]
|
|
|
|
pub struct Config {
|
|
|
|
#[serde(default)]
|
|
|
|
pub filters: FiltersConfig,
|
|
|
|
|
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub collapse_content_warnings: bool,
|
|
|
|
|
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub loop_videos: bool,
|
2024-05-20 08:18:15 +02:00
|
|
|
|
2024-05-23 05:52:37 +02:00
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub infinite_scroll: bool,
|
|
|
|
|
2024-05-20 08:18:15 +02:00
|
|
|
#[serde_inline_default("#BF616A".to_string())]
|
|
|
|
pub accent_color: String,
|
2024-05-12 00:11:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[serde_inline_default::serde_inline_default]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, serde_default::DefaultFromSerde)]
|
|
|
|
pub struct FiltersConfig {
|
2024-05-23 22:35:34 +02:00
|
|
|
#[serde_inline_default(false)]
|
|
|
|
pub replies: bool,
|
|
|
|
|
2024-05-12 00:11:28 +02:00
|
|
|
#[serde_inline_default(false)]
|
|
|
|
pub likes: bool,
|
|
|
|
|
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub creates: bool,
|
|
|
|
|
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub announces: bool,
|
|
|
|
|
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub follows: bool,
|
|
|
|
|
2024-05-31 15:54:22 +02:00
|
|
|
#[serde_inline_default(false)]
|
|
|
|
pub updates: bool,
|
|
|
|
|
2024-05-12 00:11:28 +02:00
|
|
|
#[serde_inline_default(true)]
|
|
|
|
pub orphans: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FiltersConfig {
|
2024-05-31 15:54:22 +02:00
|
|
|
pub fn visible(&self, item: &crate::Object) -> bool {
|
|
|
|
use apb::{Object, Activity};
|
|
|
|
|
|
|
|
let type_filter = match item.object_type().unwrap_or(apb::ObjectType::Object) {
|
2024-05-12 00:11:28 +02:00
|
|
|
apb::ObjectType::Note | apb::ObjectType::Document(_) => self.orphans,
|
2024-05-14 19:05:30 +02:00
|
|
|
apb::ObjectType::Activity(apb::ActivityType::Like | apb::ActivityType::EmojiReact) => self.likes,
|
2024-05-12 00:11:28 +02:00
|
|
|
apb::ObjectType::Activity(apb::ActivityType::Create) => self.creates,
|
|
|
|
apb::ObjectType::Activity(apb::ActivityType::Announce) => self.announces,
|
2024-05-31 15:54:22 +02:00
|
|
|
apb::ObjectType::Activity(apb::ActivityType::Update) => self.updates,
|
2024-05-12 00:11:28 +02:00
|
|
|
apb::ObjectType::Activity(
|
|
|
|
apb::ActivityType::Follow | apb::ActivityType::Accept(_) | apb::ActivityType::Reject(_)
|
|
|
|
) => self.follows,
|
|
|
|
_ => true,
|
2024-05-31 15:54:22 +02:00
|
|
|
};
|
|
|
|
let mut reply_filter = true;
|
|
|
|
|
|
|
|
if
|
2024-06-01 01:49:10 +02:00
|
|
|
item.in_reply_to().id().is_ok() ||
|
2024-05-31 15:54:22 +02:00
|
|
|
item.object().get().map(|x|
|
2024-06-01 01:49:10 +02:00
|
|
|
x.in_reply_to().id().is_ok()
|
2024-05-31 15:54:22 +02:00
|
|
|
).unwrap_or(false)
|
|
|
|
{
|
|
|
|
reply_filter = self.replies;
|
|
|
|
};
|
|
|
|
|
|
|
|
type_filter && reply_filter
|
2024-05-12 00:11:28 +02:00
|
|
|
}
|
|
|
|
}
|