diff options
author | 2021-06-17 18:02:33 +0200 | |
---|---|---|
committer | 2021-06-17 18:02:33 +0200 | |
commit | 82d9f88e424fffacfa9a9c1c26f2f702b97f3e3a (patch) | |
tree | 60379f8eb809e9019222f67a13b547e4a26bfc83 /internal/typeutils/util.go | |
parent | Timeline manager (#40) (diff) | |
download | gotosocial-82d9f88e424fffacfa9a9c1c26f2f702b97f3e3a.tar.xz |
Timeline improvements (#41)
Tidying up.
Parent/child statuses now display correctly in status/id/context.
Diffstat (limited to 'internal/typeutils/util.go')
-rw-r--r-- | internal/typeutils/util.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/typeutils/util.go b/internal/typeutils/util.go new file mode 100644 index 000000000..1e13f0713 --- /dev/null +++ b/internal/typeutils/util.go @@ -0,0 +1,46 @@ +package typeutils + +import ( + "fmt" + + "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +) + +func (c *converter) interactionsWithStatusForAccount(s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*statusInteractions, error) { + si := &statusInteractions{} + + if requestingAccount != nil { + faved, err := c.db.StatusFavedBy(s, requestingAccount.ID) + if err != nil { + return nil, fmt.Errorf("error checking if requesting account has faved status: %s", err) + } + si.Faved = faved + + reblogged, err := c.db.StatusRebloggedBy(s, requestingAccount.ID) + if err != nil { + return nil, fmt.Errorf("error checking if requesting account has reblogged status: %s", err) + } + si.Reblogged = reblogged + + muted, err := c.db.StatusMutedBy(s, requestingAccount.ID) + if err != nil { + return nil, fmt.Errorf("error checking if requesting account has muted status: %s", err) + } + si.Muted = muted + + bookmarked, err := c.db.StatusBookmarkedBy(s, requestingAccount.ID) + if err != nil { + return nil, fmt.Errorf("error checking if requesting account has bookmarked status: %s", err) + } + si.Bookmarked = bookmarked + } + return si, nil +} + +// StatusInteractions denotes interactions with a status on behalf of an account. +type statusInteractions struct { + Faved bool + Muted bool + Bookmarked bool + Reblogged bool +} |