-
-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Featured Posts #2585
Conversation
src/api_routes.rs
Outdated
@@ -181,7 +181,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { | |||
web::post().to(route_post::<MarkPostAsRead>), | |||
) | |||
.route("/lock", web::post().to(route_post::<LockPost>)) | |||
.route("/sticky", web::post().to(route_post::<StickyPost>)) | |||
.route("/feature_post", web::post().to(route_post::<FeaturePost>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, might be better to leave it for later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data structure is also breaking, we can just wait to merge until after 0.17.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So leave the route as "/sticky"?
published: agg.published, | ||
newest_comment_time_necro: inserted_post.published, | ||
newest_comment_time: inserted_post.published, | ||
featured_community: false, | ||
featured_local: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably do ..Default::default()
and remove explicit values like featured_local: false
, score: 0
etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave that for future work, as none of the other structs are doing this currently it seems like.
@@ -82,7 +82,7 @@ pub enum ModlogActionType { | |||
All, | |||
ModRemovePost, | |||
ModLockPost, | |||
ModStickyPost, | |||
ModFeaturePost, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will also have to add a mod log entry for AdminFeaturePost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the existing table is pry better, then you don't have to do the views again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can always add another column to differentiate between local/community feature?
src/api_routes.rs
Outdated
@@ -181,7 +181,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) { | |||
web::post().to(route_post::<MarkPostAsRead>), | |||
) | |||
.route("/lock", web::post().to(route_post::<LockPost>)) | |||
.route("/sticky", web::post().to(route_post::<StickyPost>)) | |||
.route("/feature_post", web::post().to(route_post::<FeaturePost>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data structure is also breaking, we can just wait to merge until after 0.17.0
@@ -82,7 +82,7 @@ pub enum ModlogActionType { | |||
All, | |||
ModRemovePost, | |||
ModLockPost, | |||
ModStickyPost, | |||
ModFeaturePost, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the existing table is pry better, then you don't have to do the views again.
bac4bab
to
2e3ef32
Compare
alter table post_aggregates DROP COLUMN stickied; | ||
|
||
alter table mod_sticky_post | ||
rename column stickied TO featured; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still needs some column to differentiate between local and community. Can be a boolean, or an enum, your choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 'is_featured_community' bool on table
3a50f0c
to
8a337f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
crates/db_schema/src/schema.rs
Outdated
id -> Int4, | ||
mod_person_id -> Int4, | ||
post_id -> Int4, | ||
stickied -> Nullable<Bool>, | ||
is_featured_community -> Bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope these are in the correct order, not sure if compile would fail if they're not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha it compiled, but when reading from the database the bools were in the wrong place. I just ran into the bug while testing today lol
I'll make sure @Nutomic approve too before merging. |
crates/apub/src/objects/post.rs
Outdated
embed_title, | ||
embed_description, | ||
embed_video_url, | ||
thumbnail_url, | ||
ap_id: Some(page.id.clone().into()), | ||
local: Some(false), | ||
language_id, | ||
featured_community: page.stickied, | ||
featured_local: Some(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its possible that a local admin features a remote post. In case the post creator edits the post, this would overwrite the value for featured. You should just set None here so it keeps the existing value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay fixed
crates/apub/src/objects/post.rs
Outdated
@@ -227,7 +228,8 @@ impl ApubObject for ApubPost { | |||
.community_id(community.id) | |||
.ap_id(Some(page.id.clone().into())) | |||
.locked(page.comments_enabled.map(|e| !e)) | |||
.stickied(page.stickied) | |||
.featured_community(page.stickied) | |||
.featured_local(Some(false)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (you can just remove the line).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay fixed
CI wasnt working properly for this repo, hopefully its fixed now. Anyway there is a clippy error that needs to be fixed:
|
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Looks like the federation tests have failed. Looks like this will have to wait until the lemmy-js-client is updated. |
ecca940
to
11d6eaf
Compare
11d6eaf
to
03cf988
Compare
This is the backend changes for adding Featured Posts (Local and Community) (#2067). Summary of changes below:
Only current uncertainty is around changes in apub, please give guidance on whether I did it properly or not.
Once this PR is approved, I will make the PRs for the frontend changes, and merge all at once.
Thanks!
Child PRS: