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

[feature] Client API endpoints + v. basic web view for pinned posts #1547

Merged
merged 6 commits into from
Feb 25, 2023

Conversation

tsmethurst
Copy link
Contributor

@tsmethurst tsmethurst commented Feb 22, 2023

Description

If this is a code change, please include a summary of what you've coded, and link to the issue(s) it closes/implements.

If this is a documentation change, please briefly describe what you've changed and why.

This pull request implements client API endpoints to allow users to pin + unpin toots (maximum 10, currently), and to allow API callers to view pinned toots when getting an account's statuses.

It also makes some minor changes to our html templates and css to show a basic view of pinned toots at the top of a profile in the web view.

This PR does not yet include logic for federating pinned posts in and out of GoToSocial, that will be in a separate PR.

closes #947

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@tsmethurst tsmethurst marked this pull request as ready for review February 22, 2023 16:28
@NyaaaWhatsUpDoc
Copy link
Member

Some questions about implementation details so far, but otherwise looking generally good. Once we've finished talking through these I'll finish reviewing :)

@@ -125,7 +139,8 @@ func (m *Module) profileGETHandler(c *gin.Context) {
"robotsMeta": robotsMeta,
"statuses": statusResp.Items,
"statuses_next": statusResp.NextLink,
"show_back_to_top": showBackToTop,
"pinned_statuses": pinnedResp.Items,
Copy link
Member

Choose a reason for hiding this comment

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

Surely this will panic if !paging, i.e. pinnedResp == nil. Would it be better to instead do var pinnedItems []any and set these within the !paging clause i.e. pinnedItem = pinnedResp.

Copy link
Member

Choose a reason for hiding this comment

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

Wait just realized that item is always allocated. But this way might be a lil' neater anywho 😇

@NyaaaWhatsUpDoc
Copy link
Member

2 final questions regarding expected behaviour just to double check this is expected behaviour that will work with existing clients. And one tiny nitpick.

But otherwise the code looks really good and once you have addressed those feel free to merge this :)

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit c27b4d7 into main Feb 25, 2023
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc deleted the status_pin_client_api branch February 25, 2023 12:16
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.

[bug] 404 when trying to pin from pinafore
3 participants