From e670c32a9147f632d06ee10c170201677ec1e12d Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 24 May 2021 18:49:48 +0200 Subject: Faves (#31) * start on federating faves * outbound federation of likes working --- internal/db/pg/pg.go | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'internal/db/pg/pg.go') diff --git a/internal/db/pg/pg.go b/internal/db/pg/pg.go index 01dc71434..7f65055d6 100644 --- a/internal/db/pg/pg.go +++ b/internal/db/pg/pg.go @@ -1037,32 +1037,32 @@ func (ps *postgresService) StatusBookmarkedBy(status *gtsmodel.Status, accountID return ps.conn.Model(>smodel.StatusBookmark{}).Where("status_id = ?", status.ID).Where("account_id = ?", accountID).Exists() } -func (ps *postgresService) FaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error) { - // first check if a fave already exists, we can just return if so - existingFave := >smodel.StatusFave{} - err := ps.conn.Model(existingFave).Where("status_id = ?", status.ID).Where("account_id = ?", accountID).Select() - if err == nil { - // fave already exists so just return nothing at all - return nil, nil - } - - // an error occurred so it might exist or not, we don't know - if err != pg.ErrNoRows { - return nil, err - } - - // it doesn't exist so create it - newFave := >smodel.StatusFave{ - AccountID: accountID, - TargetAccountID: status.AccountID, - StatusID: status.ID, - } - if _, err = ps.conn.Model(newFave).Insert(); err != nil { - return nil, err - } - - return newFave, nil -} +// func (ps *postgresService) FaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error) { +// // first check if a fave already exists, we can just return if so +// existingFave := >smodel.StatusFave{} +// err := ps.conn.Model(existingFave).Where("status_id = ?", status.ID).Where("account_id = ?", accountID).Select() +// if err == nil { +// // fave already exists so just return nothing at all +// return nil, nil +// } + +// // an error occurred so it might exist or not, we don't know +// if err != pg.ErrNoRows { +// return nil, err +// } + +// // it doesn't exist so create it +// newFave := >smodel.StatusFave{ +// AccountID: accountID, +// TargetAccountID: status.AccountID, +// StatusID: status.ID, +// } +// if _, err = ps.conn.Model(newFave).Insert(); err != nil { +// return nil, err +// } + +// return newFave, nil +// } func (ps *postgresService) UnfaveStatus(status *gtsmodel.Status, accountID string) (*gtsmodel.StatusFave, error) { // if a fave doesn't exist, we don't need to do anything -- cgit v1.2.3