Skip to content

Adding Modlog RSS feed.#5708

Merged
Nutomic merged 15 commits intomainfrom
modlog_rss
Jun 4, 2025
Merged

Adding Modlog RSS feed.#5708
Nutomic merged 15 commits intomainfrom
modlog_rss

Conversation

@dessalines
Copy link
Copy Markdown
Member

@dessalines dessalines commented May 27, 2025

This is missing a few things currently:

But its a good start, and those can be tweaked later based on feedback.

&None,
),
})
.collect::<LemmyResult<Vec<Item>>>()?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where a trait could be useful. Basically define a trait like this and implement it for all the modlog structs:

trait ModlogItem {
  fn moderator(&self) -> Option<Person>;
  fn published(&self) -> DateTime<Utc>;
  ...
}

And then change build_modlog_item to take T: ModlogItem and call these methods. Though it only makes sense if the trait can also be used elsewhere in the code. If its only needed here then we can leave it like this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed here. I agree it would make sense if we needed to match on all the other modlog types elsewhere.

Comment thread crates/routes/src/feeds.rs Outdated
});
let author = mod_
.as_ref()
.map(|mod_| format!("/u/{} <a href=\"{}\">(link)</a>", mod_.name, mod_.ap_id));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ap_id is wrong because it will link directly to remote instances for remote users. Below in build_item the author is also generated wrong if its a remote user. There is format_actor_url in markdown_links.rs that you can use for both.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed, and moved this to the ApubActor trait now.

) -> LemmyResult<Vec<Item>> {
// All of these go to your modlog url
let modlog_url = format!(
"{}/modlog?listing_type=ModeratorView",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listing_type=ModeratorView is only for post listing, not for modlog.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread crates/routes/src/feeds.rs Outdated
let guid = Some(Guid {
permalink: true,
value: url.to_owned(),
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guid means "Globally unique identifier" so it doesnt make sense to have the same url for multiple items.

https://www.w3schools.com/XML/rss_tag_guid.asp

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll set it to the action string then, since I'm not sure what else to use as a unique id.

format!("{local_protocol_and_hostname}/u/{}", self.name)
};
Ok(Url::parse(&url)?)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to deduplicate this code with a helper function. In fact that helper already exists in markdown_links.rs (format_actor_url), so you only need to move that to db_schema, then call it from here and community.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I'll do that now, while still keeping the trait functions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already is removed in the PR.

Comment thread crates/routes/src/feeds.rs Outdated
&v.moderator,
&v.mod_remove_community.published,
&modlog_url,
&format!("Removed community /c/{}", &v.community.name),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all dont respect the removed field, so if a comment is restored it will show in the feed as removed. And as this field is used for guid, it means remove, restore actions will be deduplicated by feed readers and only one of them shown.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@dessalines dessalines marked this pull request as draft June 2, 2025 13:45
@dessalines dessalines marked this pull request as ready for review June 2, 2025 20:30
"unblocked"
},
&v.instance.domain
),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these are used more than once so you can make a helper function for each of blocked, removed, banned like:

fn removed_or_added(bool: removed) -> &'static str {
  if removed {
    "Removed"
  } else {
    "Added"
  }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Nutomic Nutomic enabled auto-merge (squash) June 4, 2025 08:56
@Nutomic Nutomic merged commit 079ca69 into main Jun 4, 2025
2 checks passed
dessalines added a commit that referenced this pull request Jun 6, 2025
* Adding Modlog RSS feed.

- Fixes #3179

* Addressing PR comments

* Fixing clippy.

* Fixing markdown test.

* Creating common format_actor_url function.

* Clippy

* Adding boolean strings for remove/restore

* Addressing PR comments
@Nothing4You Nothing4You deleted the modlog_rss branch September 11, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RSS feeds for mods

2 participants