summaryrefslogtreecommitdiff
path: root/internal/processing/status/get.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-11-10 19:29:26 +0100
committerLibravatar GitHub <noreply@github.com>2023-11-10 19:29:26 +0100
commitba9d6b467a1f03447789844048d913738c843569 (patch)
tree5a464ee4a33f26e3284179582ab6d3332d9d5388 /internal/processing/status/get.go
parent[chore/bugfix/horror] Allow `expires_in` and poll choices to be parsed from s... (diff)
downloadgotosocial-ba9d6b467a1f03447789844048d913738c843569.tar.xz
[feature] Media attachment placeholders (#2331)
* [feature] Use placeholders for unknown media types * fix read of underreported small files * switch to reduce nesting * simplify cleanup
Diffstat (limited to 'internal/processing/status/get.go')
-rw-r--r--internal/processing/status/get.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/internal/processing/status/get.go b/internal/processing/status/get.go
index 8c939a61e..170dd0e53 100644
--- a/internal/processing/status/get.go
+++ b/internal/processing/status/get.go
@@ -36,8 +36,12 @@ func (p *Processor) Get(ctx context.Context, requestingAccount *gtsmodel.Account
return p.c.GetAPIStatus(ctx, requestingAccount, targetStatus)
}
-// ContextGet returns the context (previous and following posts) from the given status ID.
-func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Context, gtserror.WithCode) {
+func (p *Processor) contextGet(
+ ctx context.Context,
+ requestingAccount *gtsmodel.Account,
+ targetStatusID string,
+ convert func(context.Context, *gtsmodel.Status, *gtsmodel.Account) (*apimodel.Status, error),
+) (*apimodel.Context, gtserror.WithCode) {
targetStatus, errWithCode := p.c.GetVisibleTargetStatus(ctx, requestingAccount, targetStatusID)
if errWithCode != nil {
return nil, errWithCode
@@ -55,7 +59,7 @@ func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.
for _, status := range parents {
if v, err := p.filter.StatusVisible(ctx, requestingAccount, status); err == nil && v {
- apiStatus, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
+ apiStatus, err := convert(ctx, status, requestingAccount)
if err == nil {
context.Ancestors = append(context.Ancestors, *apiStatus)
}
@@ -73,7 +77,7 @@ func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.
for _, status := range children {
if v, err := p.filter.StatusVisible(ctx, requestingAccount, status); err == nil && v {
- apiStatus, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
+ apiStatus, err := convert(ctx, status, requestingAccount)
if err == nil {
context.Descendants = append(context.Descendants, *apiStatus)
}
@@ -82,3 +86,16 @@ func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.
return context, nil
}
+
+// ContextGet returns the context (previous and following posts) from the given status ID.
+func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Context, gtserror.WithCode) {
+ return p.contextGet(ctx, requestingAccount, targetStatusID, p.converter.StatusToAPIStatus)
+}
+
+// WebContextGet is like ContextGet, but is explicitly
+// for viewing statuses via the unauthenticated web UI.
+//
+// TODO: a more advanced threading model could be implemented here.
+func (p *Processor) WebContextGet(ctx context.Context, targetStatusID string) (*apimodel.Context, gtserror.WithCode) {
+ return p.contextGet(ctx, nil, targetStatusID, p.converter.StatusToWebStatus)
+}