From aeb65bceae97611b8931de2e954df18afedd812f Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:36:03 +0200 Subject: [feature/frontend] Better visual separation between "main" thread and "replies" (#3093) * [feature/frontend] Better web threading model * fix test * bwap * tweaks * more tweaks to wording * typo * indenting * adjust wording * aaa --- internal/web/thread.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'internal/web/thread.go') diff --git a/internal/web/thread.go b/internal/web/thread.go index 492d40103..de3d1b361 100644 --- a/internal/web/thread.go +++ b/internal/web/thread.go @@ -20,7 +20,6 @@ package web import ( "context" "encoding/json" - "errors" "fmt" "net/http" "strings" @@ -101,34 +100,20 @@ func (m *Module) threadGETHandler(c *gin.Context) { return } - // Get the status itself from the processor using provided ID and authorization (if any). - status, errWithCode := m.processor.Status().WebGet(ctx, targetStatusID) + // Get the thread context. This will fetch the target status as well. + context, errWithCode := m.processor.Status().WebContextGet(ctx, targetStatusID) if errWithCode != nil { apiutil.WebErrorHandler(c, errWithCode, instanceGet) return } // Ensure status actually belongs to target account. - if status.GetAccountID() != targetAccount.ID { + if context.Status.GetAccountID() != targetAccount.ID { err := fmt.Errorf("target account %s does not own status %s", targetUsername, targetStatusID) apiutil.WebErrorHandler(c, gtserror.NewErrorNotFound(err), instanceGet) return } - // Don't render boosts/reblogs as top-level statuses. - if status.Reblog != nil { - err := errors.New("status is a boost wrapper / reblog") - apiutil.WebErrorHandler(c, gtserror.NewErrorNotFound(err), instanceGet) - return - } - - // Fill in the rest of the thread context. - context, errWithCode := m.processor.Status().WebContextGet(ctx, targetStatusID) - if errWithCode != nil { - apiutil.WebErrorHandler(c, errWithCode, instanceGet) - return - } - // Prepare stylesheets for thread. stylesheets := make([]string, 0, 5) @@ -159,11 +144,10 @@ func (m *Module) threadGETHandler(c *gin.Context) { page := apiutil.WebPage{ Template: "thread.tmpl", Instance: instance, - OGMeta: apiutil.OGBase(instance).WithStatus(status), + OGMeta: apiutil.OGBase(instance).WithStatus(context.Status), Stylesheets: stylesheets, Javascript: []string{jsFrontend}, Extra: map[string]any{ - "status": status, "context": context, }, } -- cgit v1.2.3