summaryrefslogtreecommitdiff
path: root/internal/typeutils/util.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-02-25 13:16:30 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-25 12:16:30 +0000
commitc27b4d7ed02cdabac00c3ddedb8201b74f745ec6 (patch)
treed80f621241fd67a4e5de2d21a8c24776552175f5 /internal/typeutils/util.go
parent[chore] Update gin to v1.9.0 (#1553) (diff)
downloadgotosocial-c27b4d7ed02cdabac00c3ddedb8201b74f745ec6.tar.xz
[feature] Client API endpoints + v. basic web view for pinned posts (#1547)
* implement status pin client api + web handler * make test names + comments more descriptive * don't use separate table for status pins * remove unused add + remove checking * tidy up + add some more tests
Diffstat (limited to 'internal/typeutils/util.go')
-rw-r--r--internal/typeutils/util.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/typeutils/util.go b/internal/typeutils/util.go
index 40001e913..d11cccb2c 100644
--- a/internal/typeutils/util.go
+++ b/internal/typeutils/util.go
@@ -32,6 +32,7 @@ type statusInteractions struct {
Muted bool
Bookmarked bool
Reblogged bool
+ Pinned bool
}
func (c *converter) interactionsWithStatusForAccount(ctx context.Context, s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*statusInteractions, error) {
@@ -61,6 +62,12 @@ func (c *converter) interactionsWithStatusForAccount(ctx context.Context, s *gts
return nil, fmt.Errorf("error checking if requesting account has bookmarked status: %s", err)
}
si.Bookmarked = bookmarked
+
+ // The only time 'pinned' should be true is if the
+ // requesting account is looking at its OWN status.
+ if s.AccountID == requestingAccount.ID {
+ si.Pinned = !s.PinnedAt.IsZero()
+ }
}
return si, nil
}