Skip to content

Commit

Permalink
Fix replies url, add repliesFor method to client
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauve Signweaver committed Jun 6, 2024
1 parent 85bedac commit 52509c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APActivity } from 'activitypub-types'
import { APActivity, APObject } from 'activitypub-types'
import { fetch as signedFetch, generateKeypair } from 'http-signed-fetch'
import { KeyPair } from '../keypair.js'
import { ActorInfo } from '../schemas.js'
Expand Down Expand Up @@ -187,6 +187,13 @@ export class SocialInboxClient {
return await response.json()
}

async repliesFor (inReplyTo: string, actor: string): Promise<APObject[]> {
// TODO: Handle collection stuff and paging
const response = await this.sendRequest(GET, `/${actor}/inbox/replies/${inReplyTo}`)
const collection = await response.json()
return collection.item ?? collection.orderedItems
}

async postToInbox (activity: APActivity, actor: string = this.account): Promise<void> {
await this.sendRequest(POST, `/${actor}/inbox`, TYPE_LDJSON, activity)
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const inboxRoutes = (cfg: APIConfig, store: Store, apsystem: ActivityPubS
inReplyTo: string
}
Reply: APOrderedCollection | string
}>('/:actor/outbox/replies/:inReplyTo', {
}>('/:actor/inbox/replies/:inReplyTo', {
schema: {
params: Type.Object({
actor: Type.String(),
Expand Down

0 comments on commit 52509c3

Please sign in to comment.