From 72c91c92d0ad090bb75494d80317e481321d060a Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Mon, 17 May 2021 19:00:41 +0200 Subject: [PATCH] little fix to visibility --- internal/db/pg/pg.go | 13 +++++++------ internal/message/statusprocess.go | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/internal/db/pg/pg.go b/internal/db/pg/pg.go index 1a9502a81..d3590a027 100644 --- a/internal/db/pg/pg.go +++ b/internal/db/pg/pg.go @@ -804,6 +804,13 @@ func (ps *postgresService) StatusVisible(targetStatus *gtsmodel.Status, targetAc return false, nil } } + + // if the requesting account is mentioned in the status it should always be visible + for _, acct := range relevantAccounts.MentionedAccounts { + if acct.ID == requestingAccount.ID { + return true, nil // yep it's mentioned! + } + } } // at this point we know neither account blocks the other, or another account mentioned or otherwise referred to in the status @@ -835,12 +842,6 @@ func (ps *postgresService) StatusVisible(targetStatus *gtsmodel.Status, targetAc } return true, nil case gtsmodel.VisibilityDirect: - // make sure the requesting account is mentioned in the status - for _, acct := range relevantAccounts.MentionedAccounts { - if acct.ID == requestingAccount.ID { - return true, nil // yep it's mentioned! - } - } l.Debug("requesting account requests a status it's not mentioned in") return false, nil // it's not mentioned -_- } diff --git a/internal/message/statusprocess.go b/internal/message/statusprocess.go index 0842a9018..86a07eb4f 100644 --- a/internal/message/statusprocess.go +++ b/internal/message/statusprocess.go @@ -179,8 +179,10 @@ func (p *processor) StatusFave(authed *oauth.Auth, targetStatusID string) (*apim } // is the status faveable? - if !targetStatus.VisibilityAdvanced.Likeable { - return nil, errors.New("status is not faveable") + if targetStatus.VisibilityAdvanced != nil { + if !targetStatus.VisibilityAdvanced.Likeable { + return nil, errors.New("status is not faveable") + } } // it's visible! it's faveable! so let's fave the FUCK out of it @@ -236,8 +238,10 @@ func (p *processor) StatusBoost(authed *oauth.Auth, targetStatusID string) (*api return nil, NewErrorNotFound(errors.New("status is not visible")) } - if !targetStatus.VisibilityAdvanced.Boostable { - return nil, NewErrorForbidden(errors.New("status is not boostable")) + if targetStatus.VisibilityAdvanced != nil { + if !targetStatus.VisibilityAdvanced.Boostable { + return nil, NewErrorForbidden(errors.New("status is not boostable")) + } } // it's visible! it's boostable! so let's boost the FUCK out of it @@ -446,8 +450,10 @@ func (p *processor) StatusUnfave(authed *oauth.Auth, targetStatusID string) (*ap } // is the status faveable? - if !targetStatus.VisibilityAdvanced.Likeable { - return nil, errors.New("status is not faveable") + if targetStatus.VisibilityAdvanced != nil { + if !targetStatus.VisibilityAdvanced.Likeable { + return nil, errors.New("status is not faveable") + } } // it's visible! it's faveable! so let's unfave the FUCK out of it