diff options
Diffstat (limited to 'internal/visibility/statushometimelineable.go')
-rw-r--r-- | internal/visibility/statushometimelineable.go | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/internal/visibility/statushometimelineable.go b/internal/visibility/statushometimelineable.go index bc5f7bcb8..a3ca62fb3 100644 --- a/internal/visibility/statushometimelineable.go +++ b/internal/visibility/statushometimelineable.go @@ -1,3 +1,21 @@ +/* + GoToSocial + Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + package visibility import ( @@ -28,6 +46,13 @@ func (f *filter) StatusHometimelineable(targetStatus *gtsmodel.Status, timelineO return false, nil } + for _, m := range targetStatus.Mentions { + if m.TargetAccountID == timelineOwnerAccount.ID { + // if we're mentioned we should be able to see the post + return true, nil + } + } + // Don't timeline a status whose parent hasn't been dereferenced yet or can't be dereferenced. // If we have the reply to URI but don't have an ID for the replied-to account or the replied-to status in our database, we haven't dereferenced it yet. if targetStatus.InReplyToURI != "" && (targetStatus.InReplyToID == "" || targetStatus.InReplyToAccountID == "") { @@ -37,21 +62,21 @@ func (f *filter) StatusHometimelineable(targetStatus *gtsmodel.Status, timelineO // if a status replies to an ID we know in the database, we need to make sure we also follow the replied-to status owner account if targetStatus.InReplyToID != "" { // pin the reply to status on to this status if it hasn't been done already - if targetStatus.GTSReplyToStatus == nil { - rs := >smodel.Status{} - if err := f.db.GetByID(targetStatus.InReplyToID, rs); err != nil { + if targetStatus.InReplyTo == nil { + rs, err := f.db.GetStatusByID(targetStatus.InReplyToID) + if err != nil { return false, fmt.Errorf("StatusHometimelineable: error getting replied to status with id %s: %s", targetStatus.InReplyToID, err) } - targetStatus.GTSReplyToStatus = rs + targetStatus.InReplyTo = rs } // pin the reply to account on to this status if it hasn't been done already - if targetStatus.GTSReplyToAccount == nil { - ra := >smodel.Account{} - if err := f.db.GetByID(targetStatus.InReplyToAccountID, ra); err != nil { + if targetStatus.InReplyToAccount == nil { + ra, err := f.db.GetAccountByID(targetStatus.InReplyToAccountID) + if err != nil { return false, fmt.Errorf("StatusHometimelineable: error getting replied to account with id %s: %s", targetStatus.InReplyToAccountID, err) } - targetStatus.GTSReplyToAccount = ra + targetStatus.InReplyToAccount = ra } // if it's a reply to the timelineOwnerAccount, we don't need to check if the timelineOwnerAccount follows itself, just return true, they can see it @@ -60,7 +85,7 @@ func (f *filter) StatusHometimelineable(targetStatus *gtsmodel.Status, timelineO } // the replied-to account != timelineOwnerAccount, so make sure the timelineOwnerAccount follows the replied-to account - follows, err := f.db.Follows(timelineOwnerAccount, targetStatus.GTSReplyToAccount) + follows, err := f.db.IsFollowing(timelineOwnerAccount, targetStatus.InReplyToAccount) if err != nil { return false, fmt.Errorf("StatusHometimelineable: error checking follow from account %s to account %s: %s", timelineOwnerAccount.ID, targetStatus.InReplyToAccountID, err) } |