diff options
author | 2021-09-14 12:23:56 +0200 | |
---|---|---|
committer | 2021-09-14 12:23:56 +0200 | |
commit | 2e5dcc2929d6e6b22f370bf1b83c54d03ac1cd43 (patch) | |
tree | 3d3ce087220f8eb120e9fb132731fd30987d9922 /internal/processing | |
parent | add ap logo to readme (#228) (diff) | |
download | gotosocial-2e5dcc2929d6e6b22f370bf1b83c54d03ac1cd43.tar.xz |
Fix mentions not notifying (#230)
* set default privacy for new accounts
* teshts
* found it
* tiny change
* aaaa
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/fromfederator.go | 2 | ||||
-rw-r--r-- | internal/processing/fromfederator_test.go | 70 | ||||
-rw-r--r-- | internal/processing/search.go | 2 |
3 files changed, 72 insertions, 2 deletions
diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go index 1bf841bba..20027f2a1 100644 --- a/internal/processing/fromfederator.go +++ b/internal/processing/fromfederator.go @@ -51,7 +51,7 @@ func (p *processor) ProcessFromFederator(ctx context.Context, federatorMsg messa 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 { return err } diff --git a/internal/processing/fromfederator_test.go b/internal/processing/fromfederator_test.go index 598af5337..c58334787 100644 --- a/internal/processing/fromfederator_test.go +++ b/internal/processing/fromfederator_test.go @@ -27,6 +27,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" ) @@ -81,6 +82,75 @@ func (suite *FromFederatorTestSuite) TestProcessFederationAnnounce() { 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, + 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) { suite.Run(t, &FromFederatorTestSuite{}) } diff --git a/internal/processing/search.go b/internal/processing/search.go index 85da0d83f..2fb1f6062 100644 --- a/internal/processing/search.go +++ b/internal/processing/search.go @@ -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 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 := p.federator.DereferenceRemoteThread(ctx, authed.Account.Username, uri); err != nil { // try to deref the thread while we're here |