mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Timeline improvements (#41)
Tidying up. Parent/child statuses now display correctly in status/id/context.
This commit is contained in:
46
internal/typeutils/util.go
Normal file
46
internal/typeutils/util.go
Normal file
@ -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
|
||||
}
|
Reference in New Issue
Block a user