summaryrefslogtreecommitdiff
path: root/internal/processing/workers/fromclientapi_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <tobi.smethurst@protonmail.com>2025-05-11 13:38:13 +0000
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-11 13:38:13 +0000
commit8480a758081e84384a366a29ecee3c3103687512 (patch)
treed35f56a4b88905fb5f9c3a9f788ac2cf628c92fe /internal/processing/workers/fromclientapi_test.go
parent[bugfix] Fix a11y property warning from authorization page (#4166) (diff)
downloadgotosocial-8480a758081e84384a366a29ecee3c3103687512.tar.xz
[feature] Notify accounts when a status they've interacted with has been edited (#4157)
This pull request adds sending notifications to local accounts that have interacted with a status, if we receive or create a new edit for that status. closes https://codeberg.org/superseriousbusiness/gotosocial/issues/3991 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4157 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/processing/workers/fromclientapi_test.go')
-rw-r--r--internal/processing/workers/fromclientapi_test.go90
1 files changed, 90 insertions, 0 deletions
diff --git a/internal/processing/workers/fromclientapi_test.go b/internal/processing/workers/fromclientapi_test.go
index c643e0c70..a1027f3e0 100644
--- a/internal/processing/workers/fromclientapi_test.go
+++ b/internal/processing/workers/fromclientapi_test.go
@@ -2149,6 +2149,96 @@ func (suite *FromClientAPITestSuite) TestProcessUpdateStatusWithFollowedHashtag(
suite.checkNotWebPushed(testStructs.WebPushSender, receivingAccount.ID)
}
+// Test that when someone edits a status that's been interacted with,
+// the interacter gets a notification that the status has been edited.
+func (suite *FromClientAPITestSuite) TestProcessUpdateStatusInteractedWith() {
+ testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
+ defer testrig.TearDownTestStructs(testStructs)
+
+ var (
+ ctx = context.Background()
+ postingAccount = suite.testAccounts["local_account_1"]
+ receivingAccount = suite.testAccounts["admin_account"]
+ streams = suite.openStreams(ctx,
+ testStructs.Processor,
+ receivingAccount,
+ nil,
+ )
+ notifStream = streams[stream.TimelineNotifications]
+ )
+
+ // Copy the test status.
+ //
+ // This is one that the receiving account
+ // has interacted with (by replying).
+ testStatus := new(gtsmodel.Status)
+ *testStatus = *suite.testStatuses["local_account_1_status_1"]
+
+ // Create + store an edit.
+ edit := &gtsmodel.StatusEdit{
+ // Just set the ID + status ID, other
+ // fields don't matter for this test.
+ ID: "01JTR74W15VS6A6MK15N5JVJ55",
+ StatusID: testStatus.ID,
+ }
+
+ if err := testStructs.State.DB.PutStatusEdit(ctx, edit); err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ // Set edit on status as
+ // it would be for real.
+ testStatus.EditIDs = []string{edit.ID}
+ testStatus.Edits = []*gtsmodel.StatusEdit{edit}
+
+ // Update the status.
+ if err := testStructs.Processor.Workers().ProcessFromClientAPI(
+ ctx,
+ &messages.FromClientAPI{
+ APObjectType: ap.ObjectNote,
+ APActivityType: ap.ActivityUpdate,
+ GTSModel: testStatus,
+ Origin: postingAccount,
+ },
+ ); err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ // Wait for a notification to appear for the status.
+ var notif *gtsmodel.Notification
+ if !testrig.WaitFor(func() bool {
+ var err error
+ notif, err = testStructs.State.DB.GetNotification(
+ ctx,
+ gtsmodel.NotificationUpdate,
+ receivingAccount.ID,
+ postingAccount.ID,
+ edit.ID,
+ )
+ return err == nil
+ }) {
+ suite.FailNow("timed out waiting for edited status notification")
+ }
+
+ apiNotif, err := testStructs.TypeConverter.NotificationToAPINotification(ctx, notif, nil, nil)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ notifJSON, err := json.Marshal(apiNotif)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+
+ // Check notif in stream.
+ suite.checkStreamed(
+ notifStream,
+ true,
+ string(notifJSON),
+ stream.EventTypeNotification,
+ )
+}
+
func (suite *FromClientAPITestSuite) TestProcessStatusDelete() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)