-
-
Notifications
You must be signed in to change notification settings - Fork 29
🐛 Fixed private mentions being treated as public #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0629e08
47a23dd
55b28cb
1ee4332
5060267
50d0f4c
11e153d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| Feature: Incoming mentions | ||
|
|
||
| Scenario: We receive a Create(Note) with a mention | ||
| Scenario: We receive a public mention from someone | ||
| Given an Actor "Person(Alice)" | ||
| And a "Create(Note)" Activity "Note" by "Alice" with content "Hello @index@site.com" that mentions "Us" | ||
| When "Alice" sends "Note" to the Inbox | ||
| Then the request is accepted | ||
| When "Alice" sends us a public mention | ||
| And the mention is in our notifications | ||
|
|
||
| Scenario: We receive a private mention from someone | ||
| Given an Actor "Person(Alice)" | ||
| When "Alice" sends us a private mention | ||
| And the mention is not in our notifications | ||
sagzy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import { Then, When } from '@cucumber/cucumber'; | ||
|
|
||
| import assert from 'node:assert'; | ||
|
|
||
| import { createActivity, createObject } from '../support/fixtures.js'; | ||
| import { waitForItemInNotifications } from '../support/notifications.js'; | ||
| import { fetchActivityPub } from '../support/request.js'; | ||
|
|
||
| When('{string} sends us a public mention', async function (actorName) { | ||
| const actor = this.actors[actorName]; | ||
| if (!actor) { | ||
| throw new Error( | ||
| `Actor ${actorName} not found - did you forget a step?`, | ||
| ); | ||
| } | ||
|
|
||
| // Use the existing local actor (Us) from the test context | ||
| const localActor = this.actors.Us; | ||
| if (!localActor) { | ||
| throw new Error('Local actor (Us) not found in test context'); | ||
| } | ||
|
|
||
| const mention = `@${localActor.preferredUsername}@self.test`; | ||
| const tags = [ | ||
| { | ||
| type: 'Mention', | ||
| name: mention, | ||
| href: localActor.id, | ||
| }, | ||
| ]; | ||
|
|
||
| // Create a public Note with the mention (uses defaults: to='as:Public') | ||
| const object = await createObject('Note', actor, `Hello ${mention}`, tags); | ||
| const activity = await createActivity('Create', object, actor); | ||
|
|
||
| await fetchActivityPub('https://self.test/.ghost/activitypub/inbox/index', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/ld+json', | ||
| }, | ||
| body: JSON.stringify(activity), | ||
| }); | ||
|
|
||
| this.mentionId = object.id; | ||
| this.activities['Create(Note)'] = activity; | ||
| this.objects.Note = object; | ||
| }); | ||
|
|
||
| When('{string} sends us a private mention', async function (actorName) { | ||
| const actor = this.actors[actorName]; | ||
| if (!actor) { | ||
| throw new Error( | ||
| `Actor ${actorName} not found - did you forget a step?`, | ||
| ); | ||
| } | ||
|
|
||
| // Use the existing local actor (Us) from the test context | ||
| const localActor = this.actors.Us; | ||
| if (!localActor) { | ||
| throw new Error('Local actor (Us) not found in test context'); | ||
| } | ||
|
|
||
| const mention = `@${localActor.preferredUsername}@self.test`; | ||
| const tags = [ | ||
| { | ||
| type: 'Mention', | ||
| name: mention, | ||
| href: localActor.id, | ||
| }, | ||
| ]; | ||
|
|
||
| // Create a Note with the mention | ||
| const object = await createObject('Note', actor, `Hello ${mention}`, tags); | ||
|
|
||
| // Make it private by addressing it only to the mentioned user | ||
| object.to = localActor.id; | ||
| object.cc = []; | ||
|
|
||
| const activity = await createActivity('Create', object, actor); | ||
| activity.to = localActor.id; | ||
| activity.cc = []; | ||
|
|
||
| await fetchActivityPub('https://self.test/.ghost/activitypub/inbox/index', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/ld+json', | ||
| }, | ||
| body: JSON.stringify(activity), | ||
| }); | ||
|
|
||
| this.mentionId = object.id; | ||
| this.activities['Create(Note)'] = activity; | ||
| this.objects.Note = object; | ||
| }); | ||
|
|
||
| Then('the mention is in our notifications', async function () { | ||
| if (!this.mentionId) { | ||
| throw new Error( | ||
| 'You need to call a step which creates a mention before this', | ||
| ); | ||
| } | ||
|
|
||
| const found = await waitForItemInNotifications(this.mentionId); | ||
| assert(found, `Expected mention ${this.mentionId} to be in notifications`); | ||
| }); | ||
|
|
||
| Then('the mention is not in our notifications', async function () { | ||
| if (!this.mentionId) { | ||
| throw new Error( | ||
| 'You need to call a step which creates a mention before this', | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| await waitForItemInNotifications(this.mentionId); | ||
| assert.fail( | ||
| `Expected mention ${this.mentionId} to not be in notifications`, | ||
| ); | ||
| } catch (error) { | ||
| assert.equal( | ||
| error.message, | ||
| `Max retries reached when waiting on item in notifications`, | ||
| ); | ||
| } | ||
| }); | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.