async started() { for (let containerPath of this.settings.containers) { const containerUri = urlJoin(this.settings.baseUrl, containerPath); const exists = await this.actions.exist({ containerUri }); if (!exists) { console.log(`Container ${containerUri} doesn't exist, creating it...`); await this.actions.create({ containerUri }); } } }
async generate(ctx) { let userId = ctx.meta.webId || ctx.params.userId, action = ctx.params.action; if (!userId || !action || !this.settings.allowedActions.includes(action)) { throw new MoleculerError('Bad request', 400, 'BAD_REQUEST'); } if (!userId.startsWith('http')) userId = urlJoin(this.settings.usersContainer, userId); const webhook = await this.actions.create({ '@type': 'Webhook', action, user: userId }); return webhook['@id']; }
/** * Find an entity by ID. */ findById(_id) { if (!_id.startsWith('http')) { _id = urlJoin(this.service.schema.settings.containerUri, _id); } return this.broker.call(this.resourceService + '.get', { resourceUri: _id, queryDepth: this.service.schema.settings.queryDepth, jsonContext: this.service.schema.settings.context, accept: MIME_TYPES.JSON }); }
async listFollowers(ctx) { ctx.meta.$responseType = 'application/ld+json'; const collection = await ctx.call('activitypub.collection.get', { id: urlJoin(this.settings.actorsContainer, ctx.params.username, 'followers'), dereferenceItems: false }); if (collection) { return collection; } else { ctx.meta.$statusCode = 404; } }
getInboxUri(username) { return urlJoin(this.settings.actorsContainer, username, 'inbox'); }
getApiRoutes() { let routes = []; // Associate all containers in settings with the LDP service for (let containerPath of this.settings.containers) { routes.push(...getContainerRoutes(urlJoin(this.settings.baseUrl, containerPath))); } return routes; }
buildUrl(name, ...params) { return urlJoin(this.host, this.buildPath(name, ...params)); }
getFollowersUri(actorUri) { return urlJoin(actorUri, 'followers'); }
async started() { for (let containerPath of this.settings.containers) { const containerUri = urlJoin(this.settings.baseUrl, containerPath); const exists = await this.actions.exist({ containerUri }); if (!exists) { console.log(`Container ${containerUri} doesn't exist, creating it...`); await this.actions.create({ containerUri }); } } }
async listFollowing(ctx) { ctx.meta.$responseType = 'application/ld+json'; const collection = await ctx.call('activitypub.collection.get', { id: urlJoin(this.settings.actorsContainer, ctx.params.username, 'following'), dereferenceItems: false }); if (collection) { return collection; } else { ctx.meta.$statusCode = 404; } }
async listFollowing(ctx) { ctx.meta.$responseType = 'application/ld+json'; const collection = await ctx.call('activitypub.collection.get', { id: urlJoin(this.settings.actorsContainer, ctx.params.username, 'following'), dereferenceItems: false }); if (collection) { return collection; } else { ctx.meta.$statusCode = 404; } }
getApiRoutes() { let routes = []; // Associate all containers in settings with the LDP service for (let containerPath of this.settings.containers) { routes.push(...getContainerRoutes(urlJoin(this.settings.baseUrl, containerPath))); } return routes; }
async listFollowers(ctx) { ctx.meta.$responseType = 'application/ld+json'; const collection = await ctx.call('activitypub.collection.get', { id: urlJoin(this.settings.actorsContainer, ctx.params.username, 'followers'), dereferenceItems: false }); if (collection) { return collection; } else { ctx.meta.$statusCode = 404; } }
getOutboxUri(username) { return urlJoin(this.settings.actorsContainer, username, 'outbox'); }