mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@ -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
|
||||
// We need to change our response slightly if the
|
||||
// profile visitor is paging through statuses.
|
||||
var (
|
||||
paging bool
|
||||
pinnedResp = &apimodel.PageableResponse{}
|
||||
maxStatusID string
|
||||
)
|
||||
|
||||
maxStatusID := ""
|
||||
maxStatusIDString := c.Query(MaxStatusIDKey)
|
||||
if maxStatusIDString != "" {
|
||||
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"},
|
||||
})
|
||||
|
Reference in New Issue
Block a user