mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
Database updates (#144)
* start moving some database stuff around * continue moving db stuff around * more fiddling * more updates * and some more * and yet more * i broke SOMETHING but what, it's a mystery * tidy up * vendor ttlcache * use ttlcache * fix up some tests * rename some stuff * little reminder * some more updates
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user