diff options
author | 2023-02-25 13:16:30 +0100 | |
---|---|---|
committer | 2023-02-25 12:16:30 +0000 | |
commit | c27b4d7ed02cdabac00c3ddedb8201b74f745ec6 (patch) | |
tree | d80f621241fd67a4e5de2d21a8c24776552175f5 /internal/web/profile.go | |
parent | [chore] Update gin to v1.9.0 (#1553) (diff) | |
download | gotosocial-c27b4d7ed02cdabac00c3ddedb8201b74f745ec6.tar.xz |
[feature] Client API endpoints + v. basic web view for pinned posts (#1547)
* implement status pin client api + web handler
* make test names + comments more descriptive
* don't use separate table for status pins
* remove unused add + remove checking
* tidy up + add some more tests
Diffstat (limited to 'internal/web/profile.go')
-rw-r--r-- | internal/web/profile.go | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/internal/web/profile.go b/internal/web/profile.go index 2319e5dc9..a5816901e 100644 --- a/internal/web/profile.go +++ b/internal/web/profile.go @@ -91,15 +91,17 @@ func (m *Module) profileGETHandler(c *gin.Context) { robotsMeta = robotsMetaAllowSome } - // we should only show the 'back to top' button if the - // profile visitor is paging through statuses - showBackToTop := false - - maxStatusID := "" - maxStatusIDString := c.Query(MaxStatusIDKey) - if maxStatusIDString != "" { + // We need to change our response slightly if the + // profile visitor is paging through statuses. + var ( + paging bool + pinnedResp = &apimodel.PageableResponse{} + maxStatusID string + ) + + if maxStatusIDString := c.Query(MaxStatusIDKey); maxStatusIDString != "" { maxStatusID = maxStatusIDString - showBackToTop = true + paging = true } statusResp, errWithCode := m.processor.Account().WebStatusesGet(ctx, account.ID, maxStatusID) @@ -108,6 +110,18 @@ func (m *Module) profileGETHandler(c *gin.Context) { return } + // If we're not paging, then the profile visitor + // is currently just opening the bare profile, so + // load pinned statuses so we can show them at the + // top of the profile. + if !paging { + pinnedResp, errWithCode = m.processor.Account().StatusesGet(ctx, authed.Account, account.ID, 0, false, false, "", "", true, false, false) + if errWithCode != nil { + apiutil.ErrorHandler(c, errWithCode, instanceGet) + return + } + } + stylesheets := []string{ assetsPathPrefix + "/Fork-Awesome/css/fork-awesome.min.css", distPathPrefix + "/status.css", @@ -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, + "show_back_to_top": paging, "stylesheets": stylesheets, "javascript": []string{distPathPrefix + "/frontend.js"}, }) |