mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-30 00:56:16 -06:00
found it
This commit is contained in:
parent
a04717b033
commit
279da5ac5f
10 changed files with 99 additions and 30 deletions
|
|
@ -34,12 +34,12 @@ func (f *federator) EnrichRemoteAccount(ctx context.Context, username string, ac
|
||||||
return f.dereferencer.EnrichRemoteAccount(ctx, username, account)
|
return f.dereferencer.EnrichRemoteAccount(ctx, username, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *federator) GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent, includeChilds bool) (*gtsmodel.Status, ap.Statusable, bool, error) {
|
func (f *federator) GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent bool) (*gtsmodel.Status, ap.Statusable, bool, error) {
|
||||||
return f.dereferencer.GetRemoteStatus(ctx, username, remoteStatusID, refresh, includeParent, includeChilds)
|
return f.dereferencer.GetRemoteStatus(ctx, username, remoteStatusID, refresh, includeParent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *federator) EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent, includeChilds bool) (*gtsmodel.Status, error) {
|
func (f *federator) EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent bool) (*gtsmodel.Status, error) {
|
||||||
return f.dereferencer.EnrichRemoteStatus(ctx, username, status, includeParent, includeChilds)
|
return f.dereferencer.EnrichRemoteStatus(ctx, username, status, includeParent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *federator) DereferenceRemoteThread(ctx context.Context, username string, statusIRI *url.URL) error {
|
func (f *federator) DereferenceRemoteThread(ctx context.Context, username string, statusIRI *url.URL) error {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ func (d *deref) DereferenceAnnounce(ctx context.Context, announce *gtsmodel.Stat
|
||||||
return fmt.Errorf("DereferenceAnnounce: error dereferencing thread of boosted status: %s", err)
|
return fmt.Errorf("DereferenceAnnounce: error dereferencing thread of boosted status: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
boostedStatus, _, _, err := d.GetRemoteStatus(ctx, requestingUsername, boostedStatusURI, false, false, false)
|
boostedStatus, _, _, err := d.GetRemoteStatus(ctx, requestingUsername, boostedStatusURI, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("DereferenceAnnounce: error dereferencing remote status with id %s: %s", announce.BoostOf.URI, err)
|
return fmt.Errorf("DereferenceAnnounce: error dereferencing remote status with id %s: %s", announce.BoostOf.URI, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ type Dereferencer interface {
|
||||||
GetRemoteAccount(ctx context.Context, username string, remoteAccountID *url.URL, refresh bool) (*gtsmodel.Account, bool, error)
|
GetRemoteAccount(ctx context.Context, username string, remoteAccountID *url.URL, refresh bool) (*gtsmodel.Account, bool, error)
|
||||||
EnrichRemoteAccount(ctx context.Context, username string, account *gtsmodel.Account) (*gtsmodel.Account, error)
|
EnrichRemoteAccount(ctx context.Context, username string, account *gtsmodel.Account) (*gtsmodel.Account, error)
|
||||||
|
|
||||||
GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent, includeChilds bool) (*gtsmodel.Status, ap.Statusable, bool, error)
|
GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent bool) (*gtsmodel.Status, ap.Statusable, bool, error)
|
||||||
EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent, includeChilds bool) (*gtsmodel.Status, error)
|
EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent bool) (*gtsmodel.Status, error)
|
||||||
|
|
||||||
GetRemoteInstance(ctx context.Context, username string, remoteInstanceURI *url.URL) (*gtsmodel.Instance, error)
|
GetRemoteInstance(ctx context.Context, username string, remoteInstanceURI *url.URL) (*gtsmodel.Instance, error)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ import (
|
||||||
//
|
//
|
||||||
// EnrichRemoteStatus is mostly useful for calling after a status has been initially created by
|
// EnrichRemoteStatus is mostly useful for calling after a status has been initially created by
|
||||||
// the federatingDB's Create function, but additional dereferencing is needed on it.
|
// the federatingDB's Create function, but additional dereferencing is needed on it.
|
||||||
func (d *deref) EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent, includeChilds bool) (*gtsmodel.Status, error) {
|
func (d *deref) EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent bool) (*gtsmodel.Status, error) {
|
||||||
if err := d.populateStatusFields(ctx, status, username, includeParent, includeChilds); err != nil {
|
if err := d.populateStatusFields(ctx, status, username, includeParent); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ func (d *deref) EnrichRemoteStatus(ctx context.Context, username string, status
|
||||||
// If a dereference was performed, then the function also returns the ap.Statusable representation for further processing.
|
// If a dereference was performed, then the function also returns the ap.Statusable representation for further processing.
|
||||||
//
|
//
|
||||||
// SIDE EFFECTS: remote status will be stored in the database, and the remote status owner will also be stored.
|
// SIDE EFFECTS: remote status will be stored in the database, and the remote status owner will also be stored.
|
||||||
func (d *deref) GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent, includeChilds bool) (*gtsmodel.Status, ap.Statusable, bool, error) {
|
func (d *deref) GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent bool) (*gtsmodel.Status, ap.Statusable, bool, error) {
|
||||||
new := true
|
new := true
|
||||||
|
|
||||||
// check if we already have the status in our db
|
// check if we already have the status in our db
|
||||||
|
|
@ -105,7 +105,7 @@ func (d *deref) GetRemoteStatus(ctx context.Context, username string, remoteStat
|
||||||
}
|
}
|
||||||
gtsStatus.ID = ulid
|
gtsStatus.ID = ulid
|
||||||
|
|
||||||
if err := d.populateStatusFields(ctx, gtsStatus, username, includeParent, includeChilds); err != nil {
|
if err := d.populateStatusFields(ctx, gtsStatus, username, includeParent); err != nil {
|
||||||
return nil, statusable, new, fmt.Errorf("GetRemoteStatus: error populating status fields: %s", err)
|
return nil, statusable, new, fmt.Errorf("GetRemoteStatus: error populating status fields: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +115,7 @@ func (d *deref) GetRemoteStatus(ctx context.Context, username string, remoteStat
|
||||||
} else {
|
} else {
|
||||||
gtsStatus.ID = maybeStatus.ID
|
gtsStatus.ID = maybeStatus.ID
|
||||||
|
|
||||||
if err := d.populateStatusFields(ctx, gtsStatus, username, includeParent, includeChilds); err != nil {
|
if err := d.populateStatusFields(ctx, gtsStatus, username, includeParent); err != nil {
|
||||||
return nil, statusable, new, fmt.Errorf("GetRemoteStatus: error populating status fields: %s", err)
|
return nil, statusable, new, fmt.Errorf("GetRemoteStatus: error populating status fields: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ func (d *deref) dereferenceStatusable(ctx context.Context, username string, remo
|
||||||
// This function will deference all of the above, insert them in the database as necessary,
|
// This function will deference all of the above, insert them in the database as necessary,
|
||||||
// and attach them to the status. The status itself will not be added to the database yet,
|
// and attach them to the status. The status itself will not be added to the database yet,
|
||||||
// that's up the caller to do.
|
// that's up the caller to do.
|
||||||
func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Status, requestingUsername string, includeParent, includeChilds bool) error {
|
func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Status, requestingUsername string, includeParent bool) error {
|
||||||
l := d.log.WithFields(logrus.Fields{
|
l := d.log.WithFields(logrus.Fields{
|
||||||
"func": "dereferenceStatusFields",
|
"func": "dereferenceStatusFields",
|
||||||
"status": fmt.Sprintf("%+v", status),
|
"status": fmt.Sprintf("%+v", status),
|
||||||
|
|
@ -275,12 +275,10 @@ func (d *deref) populateStatusFields(ctx context.Context, status *gtsmodel.Statu
|
||||||
// 3. Emojis
|
// 3. Emojis
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// 4. Mentions (only if requested)
|
// 4. Mentions
|
||||||
// TODO: do we need to handle removing empty mention objects and just using mention IDs slice?
|
// TODO: do we need to handle removing empty mention objects and just using mention IDs slice?
|
||||||
if includeChilds {
|
if err := d.populateStatusMentions(ctx, status, requestingUsername); err != nil {
|
||||||
if err := d.populateStatusMentions(ctx, status, requestingUsername); err != nil {
|
return fmt.Errorf("populateStatusFields: error populating status mentions: %s", err)
|
||||||
return fmt.Errorf("populateStatusFields: error populating status mentions: %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Replied-to-status (only if requested)
|
// 5. Replied-to-status (only if requested)
|
||||||
|
|
@ -325,10 +323,10 @@ func (d *deref) populateStatusMentions(ctx context.Context, status *gtsmodel.Sta
|
||||||
errs := []string{}
|
errs := []string{}
|
||||||
|
|
||||||
// check if account is in the db already
|
// check if account is in the db already
|
||||||
if a, err := d.db.GetAccountByURL(ctx, targetAccountURI.String()); err != nil {
|
if a, err := d.db.GetAccountByURI(ctx, targetAccountURI.String()); err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
l.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURL", targetAccountURI, a.ID)
|
l.Debugf("populateStatusMentions: got target account %s with id %s through GetAccountByURI", targetAccountURI, a.ID)
|
||||||
targetAccount = a
|
targetAccount = a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -426,7 +424,7 @@ func (d *deref) populateStatusRepliedTo(ctx context.Context, status *gtsmodel.St
|
||||||
replyToStatus, err := d.db.GetStatusByURI(ctx, status.InReplyToURI)
|
replyToStatus, err := d.db.GetStatusByURI(ctx, status.InReplyToURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Status was not in the DB, try fetch
|
// Status was not in the DB, try fetch
|
||||||
replyToStatus, _, _, err = d.GetRemoteStatus(ctx, requestingUsername, statusURI, false, false, false)
|
replyToStatus, _, _, err = d.GetRemoteStatus(ctx, requestingUsername, statusURI, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("populateStatusRepliedTo: couldn't get reply to status with uri %s: %s", status.InReplyToURI, err)
|
return fmt.Errorf("populateStatusRepliedTo: couldn't get reply to status with uri %s: %s", status.InReplyToURI, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func (suite *StatusTestSuite) TestDereferenceSimpleStatus() {
|
||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839")
|
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE4NTHKWW7THT67EF10EB839")
|
||||||
status, statusable, new, err := suite.dereferencer.GetRemoteStatus(context.Background(), fetchingAccount.Username, statusURL, false, false, false)
|
status, statusable, new, err := suite.dereferencer.GetRemoteStatus(context.Background(), fetchingAccount.Username, statusURL, false, false)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
suite.NotNil(statusable)
|
suite.NotNil(statusable)
|
||||||
|
|
@ -80,7 +80,7 @@ func (suite *StatusTestSuite) TestDereferenceStatusWithMention() {
|
||||||
fetchingAccount := suite.testAccounts["local_account_1"]
|
fetchingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE5Y30E3W4P7TRE0R98KAYQV")
|
statusURL := testrig.URLMustParse("https://unknown-instance.com/users/brand_new_person/statuses/01FE5Y30E3W4P7TRE0R98KAYQV")
|
||||||
status, statusable, new, err := suite.dereferencer.GetRemoteStatus(context.Background(), fetchingAccount.Username, statusURL, false, false, true)
|
status, statusable, new, err := suite.dereferencer.GetRemoteStatus(context.Background(), fetchingAccount.Username, statusURL, false, false)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.NotNil(status)
|
suite.NotNil(status)
|
||||||
suite.NotNil(statusable)
|
suite.NotNil(statusable)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func (d *deref) DereferenceThread(ctx context.Context, username string, statusIR
|
||||||
}
|
}
|
||||||
|
|
||||||
// first make sure we have this status in our db
|
// first make sure we have this status in our db
|
||||||
_, statusable, _, err := d.GetRemoteStatus(ctx, username, statusIRI, true, false, false)
|
_, statusable, _, err := d.GetRemoteStatus(ctx, username, statusIRI, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("DereferenceThread: error getting status with id %s: %s", statusIRI.String(), err)
|
return fmt.Errorf("DereferenceThread: error getting status with id %s: %s", statusIRI.String(), err)
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +104,7 @@ func (d *deref) iterateAncestors(ctx context.Context, username string, statusIRI
|
||||||
|
|
||||||
// If we reach here, we're looking at a remote status -- make sure we have it in our db by calling GetRemoteStatus
|
// If we reach here, we're looking at a remote status -- make sure we have it in our db by calling GetRemoteStatus
|
||||||
// We call it with refresh to true because we want the statusable representation to parse inReplyTo from.
|
// We call it with refresh to true because we want the statusable representation to parse inReplyTo from.
|
||||||
_, statusable, _, err := d.GetRemoteStatus(ctx, username, &statusIRI, true, false, false)
|
_, statusable, _, err := d.GetRemoteStatus(ctx, username, &statusIRI, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Debugf("error getting remote status: %s", err)
|
l.Debugf("error getting remote status: %s", err)
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -214,7 +214,7 @@ pageLoop:
|
||||||
foundReplies = foundReplies + 1
|
foundReplies = foundReplies + 1
|
||||||
|
|
||||||
// get the remote statusable and put it in the db
|
// get the remote statusable and put it in the db
|
||||||
_, statusable, new, err := d.GetRemoteStatus(ctx, username, itemURI, false, false, false)
|
_, statusable, new, err := d.GetRemoteStatus(ctx, username, itemURI, false, false)
|
||||||
if new && err == nil && statusable != nil {
|
if new && err == nil && statusable != nil {
|
||||||
// now iterate descendants of *that* status
|
// now iterate descendants of *that* status
|
||||||
if err := d.iterateDescendants(ctx, username, *itemURI, statusable); err != nil {
|
if err := d.iterateDescendants(ctx, username, *itemURI, statusable); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@ type Federator interface {
|
||||||
GetRemoteAccount(ctx context.Context, username string, remoteAccountID *url.URL, refresh bool) (*gtsmodel.Account, bool, error)
|
GetRemoteAccount(ctx context.Context, username string, remoteAccountID *url.URL, refresh bool) (*gtsmodel.Account, bool, error)
|
||||||
EnrichRemoteAccount(ctx context.Context, username string, account *gtsmodel.Account) (*gtsmodel.Account, error)
|
EnrichRemoteAccount(ctx context.Context, username string, account *gtsmodel.Account) (*gtsmodel.Account, error)
|
||||||
|
|
||||||
GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent, includeChilds bool) (*gtsmodel.Status, ap.Statusable, bool, error)
|
GetRemoteStatus(ctx context.Context, username string, remoteStatusID *url.URL, refresh, includeParent bool) (*gtsmodel.Status, ap.Statusable, bool, error)
|
||||||
EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent, includeChilds bool) (*gtsmodel.Status, error)
|
EnrichRemoteStatus(ctx context.Context, username string, status *gtsmodel.Status, includeParent bool) (*gtsmodel.Status, error)
|
||||||
|
|
||||||
GetRemoteInstance(ctx context.Context, username string, remoteInstanceURI *url.URL) (*gtsmodel.Instance, error)
|
GetRemoteInstance(ctx context.Context, username string, remoteInstanceURI *url.URL) (*gtsmodel.Instance, error)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func (p *processor) ProcessFromFederator(ctx context.Context, federatorMsg messa
|
||||||
return errors.New("note was not parseable as *gtsmodel.Status")
|
return errors.New("note was not parseable as *gtsmodel.Status")
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := p.federator.EnrichRemoteStatus(ctx, federatorMsg.ReceivingAccount.Username, incomingStatus, false, false)
|
status, err := p.federator.EnrichRemoteStatus(ctx, federatorMsg.ReceivingAccount.Username, incomingStatus, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||||
|
"github.com/superseriousbusiness/gotosocial/internal/id"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -81,6 +82,76 @@ func (suite *FromFederatorTestSuite) TestProcessFederationAnnounce() {
|
||||||
suite.False(notif.Read)
|
suite.False(notif.Read)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *FromFederatorTestSuite) TestProcessReplyMention() {
|
||||||
|
repliedAccount := suite.testAccounts["local_account_1"]
|
||||||
|
repliedStatus := suite.testStatuses["local_account_1_status_1"]
|
||||||
|
replyingAccount := suite.testAccounts["remote_account_1"]
|
||||||
|
replyingStatus := >smodel.Status{
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
URI: "http://fossbros-anonymous.io/users/foss_satan/statuses/106221634728637552",
|
||||||
|
URL: "http://fossbros-anonymous.io/@foss_satan/106221634728637552",
|
||||||
|
Content: `<p><span class="h-card"><a href="http://localhost:8080/@the_mighty_zork" class="u-url mention">@<span>the_mighty_zork</span></a></span> nice there it is:</p><p><a href="http://localhost:8080/users/the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY/activity" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="ellipsis">social.pixie.town/users/f0x/st</span><span class="invisible">atuses/106221628567855262/activity</span></a></p>`,
|
||||||
|
Mentions: []*gtsmodel.Mention{
|
||||||
|
{
|
||||||
|
TargetAccountURI: repliedAccount.URI,
|
||||||
|
NameString: "@the_mighty_zork@localhost:8080",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
AccountID: replyingAccount.ID,
|
||||||
|
Account: replyingAccount,
|
||||||
|
AccountURI: replyingAccount.URI,
|
||||||
|
InReplyToID: repliedStatus.ID,
|
||||||
|
InReplyToURI: repliedStatus.URI,
|
||||||
|
InReplyToAccountID: repliedAccount.ID,
|
||||||
|
Visibility: gtsmodel.VisibilityUnlocked,
|
||||||
|
ActivityStreamsType: ap.ObjectNote,
|
||||||
|
Federated: true,
|
||||||
|
Boostable: true,
|
||||||
|
Replyable: true,
|
||||||
|
Likeable: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// id the status based on the time it was created
|
||||||
|
statusID, err := id.NewULIDFromTime(replyingStatus.CreatedAt)
|
||||||
|
suite.NoError(err)
|
||||||
|
replyingStatus.ID = statusID
|
||||||
|
|
||||||
|
err = suite.db.PutStatus(context.Background(), replyingStatus)
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
err = suite.processor.ProcessFromFederator(context.Background(), messages.FromFederator{
|
||||||
|
APObjectType: ap.ObjectNote,
|
||||||
|
APActivityType: ap.ActivityCreate,
|
||||||
|
GTSModel: replyingStatus,
|
||||||
|
ReceivingAccount: suite.testAccounts["local_account_1"],
|
||||||
|
})
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
// side effects should be triggered
|
||||||
|
// 1. status should be in the database
|
||||||
|
suite.NotEmpty(replyingStatus.ID)
|
||||||
|
_, err = suite.db.GetStatusByID(context.Background(), replyingStatus.ID)
|
||||||
|
suite.NoError(err)
|
||||||
|
|
||||||
|
// 2. a notification should exist for the mention
|
||||||
|
where := []db.Where{
|
||||||
|
{
|
||||||
|
Key: "status_id",
|
||||||
|
Value: replyingStatus.ID,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
notif := >smodel.Notification{}
|
||||||
|
err = suite.db.GetWhere(context.Background(), where, notif)
|
||||||
|
suite.NoError(err)
|
||||||
|
suite.Equal(gtsmodel.NotificationMention, notif.NotificationType)
|
||||||
|
suite.Equal(replyingStatus.InReplyToAccountID, notif.TargetAccountID)
|
||||||
|
suite.Equal(replyingStatus.AccountID, notif.OriginAccountID)
|
||||||
|
suite.Equal(replyingStatus.ID, notif.StatusID)
|
||||||
|
suite.False(notif.Read)
|
||||||
|
}
|
||||||
|
|
||||||
func TestFromFederatorTestSuite(t *testing.T) {
|
func TestFromFederatorTestSuite(t *testing.T) {
|
||||||
suite.Run(t, &FromFederatorTestSuite{})
|
suite.Run(t, &FromFederatorTestSuite{})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ func (p *processor) searchStatusByURI(ctx context.Context, authed *oauth.Auth, u
|
||||||
|
|
||||||
// we don't have it locally so dereference it if we're allowed to
|
// we don't have it locally so dereference it if we're allowed to
|
||||||
if resolve {
|
if resolve {
|
||||||
status, _, _, err := p.federator.GetRemoteStatus(ctx, authed.Account.Username, uri, true, false, false)
|
status, _, _, err := p.federator.GetRemoteStatus(ctx, authed.Account.Username, uri, true, true)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err := p.federator.DereferenceRemoteThread(ctx, authed.Account.Username, uri); err != nil {
|
if err := p.federator.DereferenceRemoteThread(ctx, authed.Account.Username, uri); err != nil {
|
||||||
// try to deref the thread while we're here
|
// try to deref the thread while we're here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue