LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.22k stars 877 forks source link

Featured posts #2067

Closed not-layla closed 1 year ago

not-layla commented 2 years ago

Not a problem so ignoring the template. This will require changes to both the frontend and the backend.

Description

Featured posts are threads that are pinned site-wide above the rest of the feed.

This allows instance admins to highlight particular threads they deem important and worthy of extra visbility. On Hexbear, one slot is usually taken up by a megathread, and the other can be anything from a significant event (i.e., a memorial, the death of a ghoul, etc), to social clubs organised by members of the community.

It's unclear to me how/if this would federate.

Example

The following is how the feature is implemented in Hexbear. Of course the UI can be different if required (e.g., it could be off on the side rather than in the centre above the main feed).


The featured posts tab expanded, rest of the main feed below it:

An example of two featured posts on Hexbear

The featured posts tab collapsed, rest of the main feed below it:

An example of the featured posts tab minimised on Hexbear

dessalines commented 2 years ago

Some comments from the chat:

<@makotech222:matrix.org> While modlog filters is in review, I'm gonna try and pick up: https://github.com/LemmyNet/lemmy/issues/2067. Basic idea is to add a new column to 'post' to store 'is_featured', add a new icon for admins-only on the front-end to pin/unpin a post, and add a new collapsible section to home page to display the posts. Any thoughts on that?

Sweet! Could you call this stickied_local or local_stickied. Its going to work the same way that community stickied posts work, but for the local view.

Nutomic commented 2 years ago

@dessalines You mean that these posts would only be shown in the local timeline, not in subscribed or all? I dont think thats a good idea, because not everyone browses different timelines, so they would be easy to miss.

Regarding federation, I agree that it makes sense not to federate this at all, but only apply it to the local instance.

dessalines commented 2 years ago

Hrm... so this would show on all views? The only one I'm maybe concerned about is the difficulty with subscribed, since the featured post might be from a community you're not subscribed to, and that could be difficult filtering-wise.

Nutomic commented 2 years ago

Well if there is a user who only browses the subscribed timeline, they would never see the sticky in that case. I dont think thats desirable.

makotech222 commented 2 years ago

I think if admin stickies a post, everyone should see it regardless of subscribing to the community it originated from.

dessalines commented 2 years ago

Its doable, maybe you could rename stickied to stickied_community, and then name this one sticky . I just wanna keep that terminology, and make sure the functionality works and looks the same, whether you're looking at a front page featured / stickied, or a community's featured / stickied.

Nutomic commented 2 years ago

Instead of including these featured posts in the output of PostQueryBuilder, we could serve it over a separate endpoint. And use a database table like stickied_posts, instead of a column in community table. I think that would make the implementation easier.

dessalines commented 2 years ago

We already have some stickied sorting logic in postquerybuilder, plus you wanna minimize the # of queries and all that, and not have to have clients worry about making multiple requests. This is already done for communities, it just needs to get worked out in a similar way to the subscribed, local, and all listing_types.

Also even if we had a separate API call for this, we still wouldn't need another table, just a stickied column on the post table.

TRVLD commented 2 years ago

Hi, it is good to see a request for enhancement on sticky/pinned posts. Maybe is it possible to ensure that solution would include also pinned/featured communities, so the admins can set communities as "stickied" to prioritize them?

Also, I'd like to ask about collation, or ordering for stickied posts/communities, especially at the Communities List. Maybe would it be more effective to add order column, and allow admins to set numeric values of "order" for any post/community record instead using true/false "sticky" flag? This way they could prioritize them, and if order value for two or more would been the same then default sorting would apply for them. This would prevent volatility of ordering of featured communities/posts.

Thanks in advance!

Nutomic commented 2 years ago

@MrCzwartek Please open new issues for those requests.

dessalines commented 2 years ago

We currently have a "trending communities" on the sidebar, at least to show people new communities that have been created and give ppl the opportunity to subscribe to them. But yes it might be possible to highlight some stickied communities in some way there.

makotech222 commented 1 year ago

Alright, picking this one back up. Let me know if this plan sounds good:

Backend:

Frontend:

Open Questions:

dessalines commented 1 year ago

Would be simpler to implement if we have the enum represent NotStickied,LocalSticky,CommunitySticky

We haven't actually done enums on the postgres / diesel side, but you can just use an int, and we'll make sure the rust and typescript / other clients use enums and the correct order.

Update StickyPost endpoints to accept int parameter

👍

Update Modlog to differentiate between local sticky and community sticky

Should be as easy as changing mod_sticky_post.stickied column to an int. IE if 0 is NotStickied, then the modlog entry means that the post has been unstickied. I don't think we need to differentiate between unstickying from local vs community.

Should 'Local' stickied posts show up in subscribed feeds?

This is probably something that should be decided by the lemmy / hexbear community, but you can move forward with either way. I could see both sides having a point. Since they're kind of "announcement" type posts, maybe only on the local view for now, since it might be annoying for someone who only uses subscribed, to always see announcements.

The difficult part of this will be the query.

Also this might be the time to bring this up, but does hexbear really plan to fork again? For as fast as @Nutomic and I develop, its going to end up in the same merge hell we warned their devs about when they first forked, after about two weeks. Its hard to believe they plan to repeat the same thing that left their codebase in the dust ~1.5 years ago.

makotech222 commented 1 year ago

We are planning to move entirely to upstream. If we fork, it will be for only minor changes which will be designed to be as easy as possible to rebase.

makotech222 commented 1 year ago

Another question:

Nutomic commented 1 year ago

For federation, stickied posts should be represented as a collection, such as this: curl -H 'Accept: application/activity+json' https://mastodon.social/users/LemmyDev/collections/featured

{
  "@context": ...,
  "id":"https://mastodon.social/users/LemmyDev/collections/featured",
  "type":"OrderedCollection",
  "totalItems":1,
  "orderedItems":[
    {
      "id":"https://mastodon.social/users/LemmyDev/statuses/104246642906910728",
      "type":"Note",
      "published":"2020-05-28T14:52:14Z",
      "attributedTo":"https://mastodon.social/users/LemmyDev",
      "content":"<p>Inaugural Post for Lemmy, a decentralized, easily self-hostable <a href=\"https://mastodon.social/tags/reddit\" class=\"mention hashtag\" rel=\"tag\">#<span>reddit</span></a> / link aggregator alternative, intended to work in the <a href=\"https://mastodon.social/tags/fediverse\" class=\"mention hashtag\" rel=\"tag\">#<span>fediverse</span></a>: </p><p><a href=\"https://github.com/LemmyNet/lemmy/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://</span><span class=\"\">github.com/LemmyNet/lemmy/</span><span class=\"invisible\"></span></a></p><p><a href=\"https://mastodon.social/tags/activitypub\" class=\"mention hashtag\" rel=\"tag\">#<span>activitypub</span></a></p>",
      ...
    }
  ]
}

This is not how Lemmy represents it now, which means that its not compatible with Mastodon and possibly other projects. As we are touching featured posts anyway, it would make sense to improve the federation aspect as well.

What this means concretely for this issue is that it would be better to represent pinned posts in the database like this:

create table site_pinned_posts {
    id primary key,
    post_id int references post
}

And for community stickied posts, it would look like this. Although it doesnt have to be changed in the same pr.

create table community_pinned_posts {
    id primary key,
    post_id int references post,
    community_id int references community
}

Should a post in community 1 that is LocalStickied show up as stickied when viewing community 1? alongside any CommunityStickied posts? (I'm guessing yes, but just checking here)

You have more experience with this feature than us. It would be helpful if you explain how your current implementation works, and if that is good or should be changed for some reason.

dessalines commented 1 year ago

I disagree with adding the bridge table rather than a simple column as it is now. It would pointlessly add another query. Then we'd have to join them in code, or force the front-ends to join the collections afterwards, which is unecessary. lemmy-ui already uses the stickied column to highlight those, so local.stickied will work in the same way.

It already is, and will be easy to serve up that collections/featured on its own endpoint with the column method: select * from post where stickied = Local.Stickied order by ...

dessalines commented 1 year ago

Should a post in community 1 that is LocalStickied show up as stickied when viewing community 1? alongside any CommunityStickied posts? (I'm guessing yes, but just checking here)

Ya that's a tough one, and might be an argument for using two different columns for community_stickied and local_stickied. Also the question of: if something is LocalStickied by an admin, that means that a community mod can't unsticky it?

I could see it going either way tho. My first inclination is that because an Admin (and not the community mod) does a LocalSticky, that the community mods might not want that stickied to the top of their community.

This is getting me more and more thinking that they should be separate columns, because they are done by separate actors. IE the action sticky_to_local is only available to admins, and sticky_to_community is a separate action only available to community mods.

makotech222 commented 1 year ago

Yeah with a single column, we lose the ability to have it stickied in both. Okay, i can get on board with two columns instead of one enum column (it should also simplify the diesel layer).

Can you detail what changes you would like to be made on the federation side? I haven't touched that part of code before and I'm not familiar with the semantics of it.

dessalines commented 1 year ago

@Nutomic could assist there, the featured/collections would likely be in this apub/routes file, and would be similar to the community outbox fetch.

Nutomic commented 1 year ago

I opened a separate issue for sticky posts collection: https://github.com/LemmyNet/lemmy/issues/2575. As the featured posts from this issue wont federate, both issues are completely separate.

@makotech222 I would definitely appreciate if you want to work on that as well. You can comment in the other issue or on Matrix if anything is unclear.

dessalines commented 1 year ago

A question for both of you on your preference. I used the term "stickied" from reddit, but neither mastodon nor hexbear uses that, and prefers "featured". I'd be fine with renaming the columns "featured_community" and "featured_local", the actions as "feature post on community", "feature post on instance / site". Doesn't matter to me either way.

makotech222 commented 1 year ago

A question for both of you on your preference. I used the term "stickied" from reddit, but neither mastodon nor hexbear uses that, and prefers "featured". I'd be fine with renaming the columns "featured_community" and "featured_local", the actions as "feature post on community", "feature post on instance / site". Doesn't matter to me either way.

I'm midway on renaming sticky -> featured, but i'm realizing that a bunch of translation files also mention sticky in various languages. I can continue along without changing those files, but might want to tag it for a re-translation later?

dessalines commented 1 year ago

Just add new i18n keys for now, instead of replacing old ones. We'll eventually have to make a tool to scan to see which strings are unused, and remove them.

not-layla commented 1 year ago

On the naming thing, despite Hexbear calling them featured posts, most users still call them stickied posts in my experience, e.g. "why isn't the mega stickied to the frontpage". People also say "pinned" to the frontpage. It's mostly only admins/sitemods/devs that call them "featured" posts and it seems like most users don't know what they are when they're referred to as such, random recent example:

Screenshot 2022-11-25 at 11-34-37 Comment by StellarTabi on Hexbear

Not sure if that influences what it should be called in Lemmy :woman_shrugging: