diff --git a/internal/web/thread.go b/internal/web/thread.go index c9dd312ec..fa3167fa7 100644 --- a/internal/web/thread.go +++ b/internal/web/thread.go @@ -25,7 +25,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/oauth" ) -type StatusLink struct { +type statusLink struct { User string `uri:"user" binding:"required"` ID string `uri:"id" binding:"required"` } @@ -34,40 +34,42 @@ func (m *Module) threadTemplateHandler(c *gin.Context) { l := m.log.WithField("func", "threadTemplateGET") l.Trace("rendering thread template") - var statusLink StatusLink + ctx := c.Request.Context() - if err := c.ShouldBindUri(&statusLink); err != nil { + var uriParts statusLink + + if err := c.ShouldBindUri(&uriParts); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"}) return } - authed, err := oauth.Authed(c, false, false, false, false) // we don't really need an app here but we want everything else + authed, err := oauth.Authed(c, false, false, false, false) if err != nil { l.Errorf("error authing status GET request: %s", err) c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"}) return } - instance, err := m.processor.InstanceGet(c.Request.Context(), m.config.Host) + instance, err := m.processor.InstanceGet(ctx, m.config.Host) if err != nil { l.Debugf("error getting instance from processor: %s", err) c.JSON(http.StatusInternalServerError, gin.H{"error": "internal server error"}) return } - status, err := m.processor.StatusGet(c.Request.Context(), authed, statusLink.ID) + status, err := m.processor.StatusGet(ctx, authed, uriParts.ID) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"}) return } - println(statusLink.User[:1], statusLink.User, status.Account.Username) - if statusLink.User[:1] != "@" || statusLink.User[1:] != status.Account.Username { + println(uriParts.User[:1], uriParts.User, status.Account.Username) + if uriParts.User[:1] != "@" || uriParts.User[1:] != status.Account.Username { c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"}) return } - context, err := m.processor.StatusGetContext(c.Request.Context(), authed, statusLink.ID) + context, err := m.processor.StatusGetContext(ctx, authed, uriParts.ID) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "status not found"}) return diff --git a/testrig/testmodels.go b/testrig/testmodels.go index d03e3506b..59233a11e 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -302,7 +302,7 @@ func NewTestAccounts() map[string]*gtsmodel.Account { Username: "admin", AvatarMediaAttachmentID: "", HeaderMediaAttachmentID: "", - DisplayName: "Admin", + DisplayName: "", Fields: []gtsmodel.Field{}, Note: "", Memorial: false, @@ -540,7 +540,7 @@ func NewTestAttachments() map[string]*gtsmodel.MediaAttachment { }, }, AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", - Description: "", + Description: "90's Trent Reznor turning to the camera", ScheduledStatusID: "", Blurhash: "LEDara58O=t5EMSOENEN9]}?aK%0", Processing: 2, diff --git a/web/template/status.tmpl b/web/template/status.tmpl index 45714f0bf..343eb2d0a 100644 --- a/web/template/status.tmpl +++ b/web/template/status.tmpl @@ -1,5 +1,5 @@ -{{.Account.DisplayName}} +{{if .Account.DisplayName}}{{.Account.DisplayName}}{{else}}{{.Account.Username}}{{end}} @{{.Account.Username}}
{{if .SpoilerText}} @@ -17,7 +17,7 @@ {{range .}} {{if not .Description}} - + {{end}} {{.Description}}