Skip to content
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

Community post tags (part 2: API methods) #5389

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Community post tags (part 2: API methods) #5389

wants to merge 12 commits into from

Conversation

phiresky
Copy link
Collaborator

@phiresky phiresky commented Feb 4, 2025

This is the second part of post tags, implementing the API methods.

Database PR (merged): #4997
Original RFC: LemmyNet/rfcs#4

@@ -222,6 +225,9 @@ pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) {
.route("/icon", delete().to(delete_community_icon))
.route("/banner", post().to(upload_community_banner))
.route("/banner", delete().to(delete_community_banner))
.route("/post_tag", post().to(create_community_tag))
.route("/post_tag", put().to(update_community_tag))
.route("/post_tag", delete().to(delete_community_tag))
Copy link
Member

Choose a reason for hiding this comment

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

I would go with /tags instead, using underscore looks ugly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there's also underscore in some other api methods, and here i think it's good to be unambiguous

Copy link
Member

Choose a reason for hiding this comment

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

IMO these should be at :

  • POST /community/tag (creates)
  • PUT /community/tag (updates)
  • DELETE /community/tag (deletes)

Copy link
Collaborator Author

@phiresky phiresky Feb 11, 2025

Choose a reason for hiding this comment

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

The reason I would disagree with this is that it is pretty ambiguous. These are not "community tags" they are "post tags" in a community. Community tags could just as well be tags that admins of an instance add to communities, for example a "technology" tag to all tech communities to group them. This is something that we might want in the future, and adding ambiguity just because an "underscore looks ugly" in a place that no user will ever see seems pretty misguided to me.

Copy link
Member

Choose a reason for hiding this comment

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

I spose the naming of these could be either where they live / who they belong to, or what they apply to. In that sense these are community tags, that apply to posts. This kind of hints that we're trying to do both at once, when we should adopt one: .route("/**post_tag**", post().to(create_**community**_tag))

Doesn't matter to me too much, as long as we're consistent. I think using the ownership level makes sense tho : these community tags might also apply to comments at some point, in addition to posts.

Copy link
Member

@Nutomic Nutomic Feb 20, 2025

Choose a reason for hiding this comment

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

Yes it all needs to be made more consistent. For the main tags table community_tags makes sense, while the relation tag-post can be represented by a table community_tags_for_post. And the api endpoints should be /community/tag like mentioned above.

Copy link
Collaborator Author

@phiresky phiresky Feb 20, 2025

Choose a reason for hiding this comment

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

I can adjust it, but I don't think what either of you are saying makes any sense. both pieces of information are important. These tags belong to a community but apply to a post. So the field should be named community/available_tags_for_posts or similar. These are not tags applied to a community.

Copy link
Member

Choose a reason for hiding this comment

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

The tags are defined by the community so calling them community tags makes sense. And in the future it would also be possible to use the same tags for users.

@phiresky
Copy link
Collaborator Author

phiresky commented Feb 7, 2025

Ready for review. the API tests pass locally for me, but require merging LemmyNet/lemmy-js-client#483

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

What's the slug thing about? The tag already has a name and an ap_id.

Copy link
Member

Choose a reason for hiding this comment

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

Would probably be better to split each action into its own file, like we've done with the other API actions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you sure? seems a bit unnecessary

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't matter to me that much, but it is against the convention of all the other API actions.

@dessalines
Copy link
Member

Do the re-request review when you want me to have another look. I thought about going through it but I'm guessing its still WIP.

@phiresky
Copy link
Collaborator Author

phiresky commented Feb 18, 2025

I've updated the PR

  • comments fixed
  • removed separate API methods, post create and update now do replacement of all tags (if tags given)
  • added tagupdateform

I'll merge main after reviews are green

@Nutomic
Copy link
Member

Nutomic commented Feb 20, 2025

Api tests are failing, looks like you need to merge changes from main branch here.

let tag_name_lower = tag_name.to_lowercase();
let id_slug = VALID_ID_SLUG.replace_all(&tag_name_lower, "-");
// limit length to 40 chars
let id_slug: String = id_slug.chars().take(40).collect();
Copy link
Member

Choose a reason for hiding this comment

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

You should limit length of the tag itself when it is created.

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.

4 participants