Skip to content

Commit

Permalink
start of integration into ap datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed Nov 23, 2023
1 parent 2a0b10c commit b0cccfb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/repco-core/src/datasources/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { EntityForm } from '../entity.js'
import { HttpError } from '../util/error.js'
import { notEmpty } from '../util/misc.js'
import { getGlobalApInstance } from 'repco-activitypub'

const configSchema = zod.object({
user: zod.string(),
Expand Down Expand Up @@ -184,7 +185,31 @@ export class ActivityPubDataSource
return lastPageNumber
}

// this would be the initialization needed, roughly
// untested!!
// async getAndInitAp() {
// const remoteActorId = `@${this.config.user}@${this.config.domain}`
// const localName = this.config.repo
// const ap = getGlobalApInstance()
// if (!ap) throw new Error('activitypub is not initialized')
// // ensure actor and follow
// const actor = await ap.getOrCreateActor(localName)
// const follows = await ap.getFollows(actor.name)
// if (follows.indexOf(remoteActorId) == -1) {
// await ap.followRemoteActor(actor.name, remoteActorId)
// }
// return ap
// }

async fetchUpdates(cursorString: string | null): Promise<FetchUpdatesResult> {
// this would look for the latest updates
// first it should finish fetching the history as currently likely
// or we move that functionality to repco-activitypub
// would have to be tested, not sure if the remote servers push all history to our ap server after we follow them
// const ap = await this.getAndInitAp()
// const localActorName = this.config.repo
// const updates = await ap.getActivities(localActorName)

try {
let channelSourceRecord
// First ingest: save channel as ContentGrouping
Expand Down

0 comments on commit b0cccfb

Please sign in to comment.