feat: new compat options for lemmy......
lemmy whyyyyyyyyyy.....
This commit is contained in:
parent
0efe1a3301
commit
e15952f028
2 changed files with 59 additions and 43 deletions
|
@ -110,6 +110,9 @@ pub struct CompatibilityConfig {
|
|||
|
||||
#[serde(default)]
|
||||
pub add_explicit_target_to_likes_if_local: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub skip_single_attachment_if_image_is_set: bool,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
|
|
@ -73,8 +73,20 @@ impl Normalizer for crate::Context {
|
|||
.await?;
|
||||
}
|
||||
|
||||
// TODO this check is a bit disgusting but lemmy for some incomprehensible reason sends us
|
||||
// the same image twice: once in `image` and once as `attachment`. you may say "well just
|
||||
// check if url is the same" and i absolutely do but lemmy is 10 steps forwards and it sends
|
||||
// the same image twice with two distinct links. checkmate fedi developers!!!!!
|
||||
// so basically i don't want to clutter my timeline with double images, nor fetch every image
|
||||
// that comes from lemmy (we cloak and lazy-load) just to dedupe it...
|
||||
let attachments = object.attachment().flat();
|
||||
if !(
|
||||
self.cfg().compat.skip_single_attachment_if_image_is_set
|
||||
&& object_model.image.is_some()
|
||||
&& attachments.len() == 1
|
||||
) {
|
||||
let obj_image = object_model.image.clone().unwrap_or_default();
|
||||
for attachment in object.attachment().flat() {
|
||||
for attachment in attachments {
|
||||
let attachment_model = match attachment {
|
||||
Node::Empty => continue,
|
||||
Node::Array(_) => {
|
||||
|
@ -117,6 +129,7 @@ impl Normalizer for crate::Context {
|
|||
.exec(tx)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
for tag in object.tag().flat() {
|
||||
match tag {
|
||||
|
|
Loading…
Reference in a new issue