summaryrefslogtreecommitdiff
path: root/internal/web/thread.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-04-15 14:33:01 +0200
committerLibravatar GitHub <noreply@github.com>2022-04-15 14:33:01 +0200
commit26683b3d49beea9b1f0e8f78df4720285d4c0825 (patch)
tree06bf09cdee7a60c41947a0bd03d6a42ad83ee784 /internal/web/thread.go
parent[bugfix] Fix broken only_media and only_public flags on /api/v1/accounts/:id/... (diff)
downloadgotosocial-26683b3d49beea9b1f0e8f78df4720285d4c0825.tar.xz
[feature] Web profile pages for accounts (#449)
* add default avatars * allow webModule to error * return errWithCode from account get * add AccountGetLocalByUsername * check nil requesting account * add timestampShort function for just month/year * move loading logic to New + add default avatars * add profile page view * update swagger docs * add excludeReblogs to GetAccountStatuses * ignore casing when selecting local account by username * appropriate redirects * css fiddling * add 'about' heading * adjust thread page to work with routing * return AP representation if requested + authorized * simplify auth check * go fmt * golangci-lint ignore math/rand
Diffstat (limited to 'internal/web/thread.go')
-rw-r--r--internal/web/thread.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/internal/web/thread.go b/internal/web/thread.go
index 9c985d729..4a448690d 100644
--- a/internal/web/thread.go
+++ b/internal/web/thread.go
@@ -20,6 +20,7 @@ package web
import (
"net/http"
+ "strings"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
@@ -29,21 +30,21 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
-type statusLink struct {
- User string `uri:"user" binding:"required"`
- ID string `uri:"id" binding:"required"`
-}
-
func (m *Module) threadTemplateHandler(c *gin.Context) {
l := logrus.WithField("func", "threadTemplateGET")
l.Trace("rendering thread template")
ctx := c.Request.Context()
- var uriParts statusLink
+ username := c.Param(usernameKey)
+ if username == "" {
+ c.JSON(http.StatusBadRequest, gin.H{"error": "no account username specified"})
+ return
+ }
- if err := c.ShouldBindUri(&uriParts); err != nil {
- c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"})
+ statusID := c.Param(statusIDKey)
+ if username == "" {
+ c.JSON(http.StatusBadRequest, gin.H{"error": "no status id specified"})
return
}
@@ -62,18 +63,18 @@ func (m *Module) threadTemplateHandler(c *gin.Context) {
return
}
- status, err := m.processor.StatusGet(ctx, authed, uriParts.ID)
+ status, err := m.processor.StatusGet(ctx, authed, statusID)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"})
return
}
- if uriParts.User[:1] != "@" || uriParts.User[1:] != status.Account.Username {
+ if !strings.EqualFold(username, status.Account.Username) {
c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"})
return
}
- context, err := m.processor.StatusGetContext(ctx, authed, uriParts.ID)
+ context, err := m.processor.StatusGetContext(ctx, authed, statusID)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"})
return