Skip to content
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

setup announcement actor, add endpoint for actor #42

Merged
merged 52 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5320e9f
wip: setup announcement actor, add endpoint for actor
catdevnull Feb 13, 2024
5f04cc2
WIP: announcements post script
catdevnull Feb 13, 2024
3d25d1a
WIP
catdevnull Feb 22, 2024
58db44c
chore(vscode): always use ts-standard
catdevnull Feb 22, 2024
5687b42
announcements: add endpoints for outbox
catdevnull Feb 22, 2024
0051dea
chore: add-post-to-announcements
catdevnull Feb 22, 2024
1deddd8
chore: clean up
catdevnull Feb 22, 2024
7ed3030
feat: announce on creation
catdevnull Feb 22, 2024
58600ad
fix: correct http-signed-fetch types and related changes
catdevnull Feb 23, 2024
165557d
fix(client): remove trailing slash to setInfo endpoint
catdevnull Feb 23, 2024
f9406ed
fix: only announce if doesn't exist already
catdevnull Feb 23, 2024
3e41d81
chore: add basic client CLI
catdevnull Feb 23, 2024
1abce31
fix: try to get announcements inbox working
catdevnull Feb 23, 2024
261d120
fix: missing publicKeyId
catdevnull Feb 23, 2024
18db375
Update src/server/api/announcements.ts
catdevnull Feb 29, 2024
e8eb6c7
chore: remove TODO comment
catdevnull Feb 29, 2024
c646585
fix: sort announcements outbox by latest first
catdevnull Feb 29, 2024
fbb6006
fix: move announcements stuff to APSystem subclass, fix stuff
catdevnull Feb 29, 2024
246a1b5
chore: fix linting errors
catdevnull Feb 29, 2024
31e9b2d
fix: remove trailing slash everywhere
catdevnull Mar 4, 2024
1997e48
feat: add webfinger route
catdevnull Mar 4, 2024
59ad921
perf: check if actor already exists using `.get`
catdevnull Mar 6, 2024
a6b1fa7
chore: move outbox getter to Announcements class
catdevnull Mar 6, 2024
7a334a9
delete cli
catdevnull Mar 7, 2024
83c7488
delete client API CLI
catdevnull Mar 7, 2024
7aa12c5
fix: setup announcements actor as a normal "mention" actor
catdevnull Mar 7, 2024
551f2f5
fix: make getActor sync
catdevnull Mar 8, 2024
1f0a840
fix: generate correct mention for announcements actor
catdevnull Mar 8, 2024
f801a7a
fix: add missing fields to announcements actor activitypub
catdevnull Mar 8, 2024
0823e0f
fix: do not error when trying to announce non-existant actor
catdevnull Mar 11, 2024
b0d1dc9
chore: add test for announcements
catdevnull Mar 11, 2024
32bff3a
fix: correctly check actor presence
catdevnull Mar 11, 2024
0676758
fix: try announcing new actor before creating it
catdevnull Mar 13, 2024
a82ff74
fix: use actual DB to check if actor exists already
catdevnull Mar 13, 2024
c5c2516
fix: use announcements actor id for activity
catdevnull Mar 13, 2024
b4184a3
fix: make tests pass
catdevnull Mar 13, 2024
613d0d1
fix: prevent race condition and correctly attribute announcement acti…
catdevnull Mar 13, 2024
fa1cd98
fix: wrap announcement Note in a Create
catdevnull Mar 13, 2024
5b4e28e
fix: unused
catdevnull Mar 13, 2024
fdf3706
Fix ts error in announcement test
RangerMauve Mar 13, 2024
debdd54
Implement ActorStore.delete()
RangerMauve Mar 13, 2024
056279e
Store note separate, use mention syntax to tag new account
RangerMauve Mar 13, 2024
87de7aa
Fix linting, move actor definition into announcements
RangerMauve Mar 13, 2024
e0cfec2
Fix linting, move actor definition into announcements
RangerMauve Mar 13, 2024
1e22903
progress on fixing announcement tests
RangerMauve Mar 13, 2024
9816374
chore: move APActorNonStandard into schemas.ts
catdevnull Mar 15, 2024
600f074
fix: do not include Notes in outbox
catdevnull Mar 16, 2024
fb1fb77
fix announcements tests
RangerMauve Mar 20, 2024
13a632b
Formalize auto-accepting follow requests
RangerMauve Mar 20, 2024
2f97d57
Better ts lint friendly auto approve check
RangerMauve Mar 20, 2024
a61a483
Better ts lint friendly announce check
RangerMauve Mar 20, 2024
8a5af82
Better ts lint friendly announce check
RangerMauve Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/announcements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ test('actor gets announced on .announce', async t => {
keypair,
publicKeyId: keypair.publicKeyId
}
await aps.store.forActor(fakeActor).setInfo(actorInfo)
await aps.announcements.announce(fakeActor, actorInfo)
await aps.store.forActor(fakeActor).setInfo(actorInfo)

const outbox = await aps.store.forActor('@announcements@localhost').outbox.list()
t.is(outbox.length, 1, 'something is in outbox')
Expand Down
4 changes: 2 additions & 2 deletions src/server/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Announcements {
async announce (actor: string, info: ActorInfo): Promise<void> {
let existedAlready = false
try {
const existingActor = await this.apsystem.store.actorsDb.get(actor)
const existingActor = await this.apsystem.store.forActor(actor).getInfo()
if (existingActor !== undefined) existedAlready = true
} catch (err) {
if (!(err as { notFound: boolean }).notFound) {
Expand All @@ -73,7 +73,7 @@ export class Announcements {
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Note',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActivityStreams hold activities, not Notes. This should be wrapped in a Create activity with the Note being the object.

e.g. here's how we link to notes in the staticpub example: https://github.com/RangerMauve/staticpub.mauve.moe/blob/default/outbox.jsonld#L13

We may need to store the notes in a separate store and add a new /:actor/note/:id URL to resolve them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a requirement in the spec that states that OrderedCollections must hold Activitys. Actually, I was mostly copying off of Sutty's Jekyll implementation, which has plain Updates inside the outbox:

Am I getting something wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, notice how the update you linked wraps the note in an Update activity. We should do the same here, but with a Create.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH lol i thought Update was similar to a Note. But the ID there is just a link to the post, so do we need an endpoint for the individual Note?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might, lets see if just wrapping is enough for now though.

id: `${this.outboxUrl}/${nanoid()}`,
actor: info.actorUrl,
actor: this.actorUrl,
attributedTo: info.actorUrl,
catdevnull marked this conversation as resolved.
Show resolved Hide resolved
published: new Date().toUTCString(),
to: ['https://www.w3.org/ns/activitystreams#Public'],
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const creationRoutes = (cfg: APIConfig, store: Store, apsystem: ActivityP
}

const info = request.body
await store.forActor(actor).setInfo(info)
await apsystem.announcements.announce(actor, info)
catdevnull marked this conversation as resolved.
Show resolved Hide resolved
await store.forActor(actor).setInfo(info)
catdevnull marked this conversation as resolved.
Show resolved Hide resolved

return await reply.send(info)
})
Expand Down
Loading