add some logging, fix some bugs
This commit is contained in:
@ -963,7 +963,7 @@ func (ps *postgresService) PullRelevantAccountsFromStatus(targetStatus *gtsmodel
|
|||||||
if targetStatus.InReplyToAccountID != "" {
|
if targetStatus.InReplyToAccountID != "" {
|
||||||
repliedToAccount := >smodel.Account{}
|
repliedToAccount := >smodel.Account{}
|
||||||
if err := ps.conn.Model(repliedToAccount).Where("id = ?", targetStatus.InReplyToAccountID).Select(); err != nil {
|
if err := ps.conn.Model(repliedToAccount).Where("id = ?", targetStatus.InReplyToAccountID).Select(); err != nil {
|
||||||
return accounts, err
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting repliedToAcount with id %s: %s", targetStatus.InReplyToAccountID, err)
|
||||||
}
|
}
|
||||||
accounts.ReplyToAccount = repliedToAccount
|
accounts.ReplyToAccount = repliedToAccount
|
||||||
}
|
}
|
||||||
@ -973,11 +973,11 @@ func (ps *postgresService) PullRelevantAccountsFromStatus(targetStatus *gtsmodel
|
|||||||
// retrieve the boosted status first
|
// retrieve the boosted status first
|
||||||
boostedStatus := >smodel.Status{}
|
boostedStatus := >smodel.Status{}
|
||||||
if err := ps.conn.Model(boostedStatus).Where("id = ?", targetStatus.BoostOfID).Select(); err != nil {
|
if err := ps.conn.Model(boostedStatus).Where("id = ?", targetStatus.BoostOfID).Select(); err != nil {
|
||||||
return accounts, err
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting boostedStatus with id %s: %s", targetStatus.BoostOfID, err)
|
||||||
}
|
}
|
||||||
boostedAccount := >smodel.Account{}
|
boostedAccount := >smodel.Account{}
|
||||||
if err := ps.conn.Model(boostedAccount).Where("id = ?", boostedStatus.AccountID).Select(); err != nil {
|
if err := ps.conn.Model(boostedAccount).Where("id = ?", boostedStatus.AccountID).Select(); err != nil {
|
||||||
return accounts, err
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting boostedAccount with id %s: %s", boostedStatus.AccountID, err)
|
||||||
}
|
}
|
||||||
accounts.BoostedAccount = boostedAccount
|
accounts.BoostedAccount = boostedAccount
|
||||||
|
|
||||||
@ -985,7 +985,7 @@ func (ps *postgresService) PullRelevantAccountsFromStatus(targetStatus *gtsmodel
|
|||||||
if boostedStatus.InReplyToAccountID != "" {
|
if boostedStatus.InReplyToAccountID != "" {
|
||||||
boostedStatusRepliedToAccount := >smodel.Account{}
|
boostedStatusRepliedToAccount := >smodel.Account{}
|
||||||
if err := ps.conn.Model(boostedStatusRepliedToAccount).Where("id = ?", boostedStatus.InReplyToAccountID).Select(); err != nil {
|
if err := ps.conn.Model(boostedStatusRepliedToAccount).Where("id = ?", boostedStatus.InReplyToAccountID).Select(); err != nil {
|
||||||
return accounts, err
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting boostedStatusRepliedToAccount with id %s: %s", boostedStatus.InReplyToAccountID, err)
|
||||||
}
|
}
|
||||||
accounts.BoostedReplyToAccount = boostedStatusRepliedToAccount
|
accounts.BoostedReplyToAccount = boostedStatusRepliedToAccount
|
||||||
}
|
}
|
||||||
@ -996,12 +996,12 @@ func (ps *postgresService) PullRelevantAccountsFromStatus(targetStatus *gtsmodel
|
|||||||
|
|
||||||
mention := >smodel.Mention{}
|
mention := >smodel.Mention{}
|
||||||
if err := ps.conn.Model(mention).Where("id = ?", mentionID).Select(); err != nil {
|
if err := ps.conn.Model(mention).Where("id = ?", mentionID).Select(); err != nil {
|
||||||
return accounts, fmt.Errorf("error getting mention with id %s: %s", mentionID, err)
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting mention with id %s: %s", mentionID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mentionedAccount := >smodel.Account{}
|
mentionedAccount := >smodel.Account{}
|
||||||
if err := ps.conn.Model(mentionedAccount).Where("id = ?", mention.TargetAccountID).Select(); err != nil {
|
if err := ps.conn.Model(mentionedAccount).Where("id = ?", mention.TargetAccountID).Select(); err != nil {
|
||||||
return accounts, fmt.Errorf("error getting mentioned account: %s", err)
|
return accounts, fmt.Errorf("PullRelevantAccountsFromStatus: error getting mentioned account: %s", err)
|
||||||
}
|
}
|
||||||
accounts.MentionedAccounts = append(accounts.MentionedAccounts, mentionedAccount)
|
accounts.MentionedAccounts = append(accounts.MentionedAccounts, mentionedAccount)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,13 +76,13 @@ type Account struct {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Does this account need an approval for new followers?
|
// Does this account need an approval for new followers?
|
||||||
Locked bool
|
Locked bool `pg:",default:false"`
|
||||||
// Should this account be shown in the instance's profile directory?
|
// Should this account be shown in the instance's profile directory?
|
||||||
Discoverable bool
|
Discoverable bool `pg:",default:false"`
|
||||||
// Default post privacy for this account
|
// Default post privacy for this account
|
||||||
Privacy Visibility
|
Privacy Visibility `pg:",default:'public'"`
|
||||||
// Set posts from this account to sensitive by default?
|
// Set posts from this account to sensitive by default?
|
||||||
Sensitive bool
|
Sensitive bool `pg:",default:false"`
|
||||||
// What language does this account post in?
|
// What language does this account post in?
|
||||||
Language string `pg:",default:'en'"`
|
Language string `pg:",default:'en'"`
|
||||||
|
|
||||||
|
|||||||
@ -454,11 +454,7 @@ func (p *processor) AccountFollowCreate(authed *oauth.Auth, form *apimodel.Accou
|
|||||||
p.fromClientAPI <- gtsmodel.FromClientAPI{
|
p.fromClientAPI <- gtsmodel.FromClientAPI{
|
||||||
APObjectType: gtsmodel.ActivityStreamsFollow,
|
APObjectType: gtsmodel.ActivityStreamsFollow,
|
||||||
APActivityType: gtsmodel.ActivityStreamsCreate,
|
APActivityType: gtsmodel.ActivityStreamsCreate,
|
||||||
GTSModel: >smodel.Follow{
|
GTSModel: fr,
|
||||||
AccountID: authed.Account.ID,
|
|
||||||
TargetAccountID: form.TargetAccountID,
|
|
||||||
URI: fr.URI,
|
|
||||||
},
|
|
||||||
OriginAccount: authed.Account,
|
OriginAccount: authed.Account,
|
||||||
TargetAccount: targetAcct,
|
TargetAccount: targetAcct,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er
|
|||||||
// CREATE A FOLLOW REQUEST
|
// CREATE A FOLLOW REQUEST
|
||||||
incomingFollowRequest, ok := federatorMsg.GTSModel.(*gtsmodel.FollowRequest)
|
incomingFollowRequest, ok := federatorMsg.GTSModel.(*gtsmodel.FollowRequest)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("like was not parseable as *gtsmodel.FollowRequest")
|
return errors.New("incomingFollowRequest was not parseable as *gtsmodel.FollowRequest")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.notifyFollowRequest(incomingFollowRequest, federatorMsg.ReceivingAccount); err != nil {
|
if err := p.notifyFollowRequest(incomingFollowRequest, federatorMsg.ReceivingAccount); err != nil {
|
||||||
|
|||||||
@ -18,17 +18,17 @@ func (p *processor) HomeTimelineGet(authed *oauth.Auth, maxID string, sinceID st
|
|||||||
for _, s := range statuses {
|
for _, s := range statuses {
|
||||||
targetAccount := >smodel.Account{}
|
targetAccount := >smodel.Account{}
|
||||||
if err := p.db.GetByID(s.AccountID, targetAccount); err != nil {
|
if err := p.db.GetByID(s.AccountID, targetAccount); err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error getting status author: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error getting status author: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
relevantAccounts, err := p.db.PullRelevantAccountsFromStatus(s)
|
relevantAccounts, err := p.db.PullRelevantAccountsFromStatus(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error getting relevant statuses: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error getting relevant statuses for status with id %s and uri %s: %s", s.ID, s.URI, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
visible, err := p.db.StatusVisible(s, targetAccount, authed.Account, relevantAccounts)
|
visible, err := p.db.StatusVisible(s, targetAccount, authed.Account, relevantAccounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error checking status visibility: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error checking status visibility: %s", err))
|
||||||
}
|
}
|
||||||
if !visible {
|
if !visible {
|
||||||
continue
|
continue
|
||||||
@ -38,16 +38,16 @@ func (p *processor) HomeTimelineGet(authed *oauth.Auth, maxID string, sinceID st
|
|||||||
if s.BoostOfID != "" {
|
if s.BoostOfID != "" {
|
||||||
bs := >smodel.Status{}
|
bs := >smodel.Status{}
|
||||||
if err := p.db.GetByID(s.BoostOfID, bs); err != nil {
|
if err := p.db.GetByID(s.BoostOfID, bs); err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error getting boosted status: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error getting boosted status: %s", err))
|
||||||
}
|
}
|
||||||
boostedRelevantAccounts, err := p.db.PullRelevantAccountsFromStatus(bs)
|
boostedRelevantAccounts, err := p.db.PullRelevantAccountsFromStatus(bs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error getting relevant accounts from boosted status: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error getting relevant accounts from boosted status: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
boostedVisible, err := p.db.StatusVisible(bs, relevantAccounts.BoostedAccount, authed.Account, boostedRelevantAccounts)
|
boostedVisible, err := p.db.StatusVisible(bs, relevantAccounts.BoostedAccount, authed.Account, boostedRelevantAccounts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error checking boosted status visibility: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error checking boosted status visibility: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if boostedVisible {
|
if boostedVisible {
|
||||||
@ -57,7 +57,7 @@ func (p *processor) HomeTimelineGet(authed *oauth.Auth, maxID string, sinceID st
|
|||||||
|
|
||||||
apiStatus, err := p.tc.StatusToMasto(s, targetAccount, authed.Account, relevantAccounts.BoostedAccount, relevantAccounts.ReplyToAccount, boostedStatus)
|
apiStatus, err := p.tc.StatusToMasto(s, targetAccount, authed.Account, relevantAccounts.BoostedAccount, relevantAccounts.ReplyToAccount, boostedStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, NewErrorInternalError(fmt.Errorf("error converting status to masto: %s", err))
|
return nil, NewErrorInternalError(fmt.Errorf("HomeTimelineGet: error converting status to masto: %s", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
apiStatuses = append(apiStatuses, *apiStatus)
|
apiStatuses = append(apiStatuses, *apiStatus)
|
||||||
|
|||||||
Reference in New Issue
Block a user