mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user