Skip to content

Commit

Permalink
address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurin-W committed Sep 30, 2023
1 parent 68c27f4 commit f598f2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { MIME_TYPES } = require('@semapps/mime-types');
const { OBJECT_TYPES, ACTIVITY_TYPES } = require('../../../constants');
const { waitForResource } = require('../../../utils');

const ObjectService = {
name: 'activitypub.object',
Expand Down Expand Up @@ -52,8 +51,9 @@ const ObjectService = {

if (!container)
throw new Error(
`Cannot create resource of type "${activity.object.type ||
activity.object['@type']}", no matching containers were found!`
`Cannot create resource of type "${
activity.object.type || activity.object['@type']
}", no matching containers were found!`
);

const containerUri = await ctx.call('ldp.registry.getUri', { path: container.path, webId: actorUri });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {

// Optional get-action parameters
webId: { type: 'string', optional: true },
dereference: { type: 'array', optional: true },
jsonContext: {
type: 'multi',
rules: [{ type: 'array' }, { type: 'object' }, { type: 'string' }],
Expand All @@ -24,20 +23,17 @@ module.exports = {
async handler(ctx) {
const { resourceUri, predicates = [], delayMs = 1000, maxTries = 30, webId = 'system', ...rest } = ctx.params;

return await waitForResource(
delayMs,
predicates,
maxTries,
async () =>
(object = await ctx.call(
'ldp.resource.get',
{
resourceUri: resourceUri,
accept: MIME_TYPES.JSON,
...rest
},
{ meta: { $cache: false } }
))
return await waitForResource(delayMs, predicates, maxTries, () =>
ctx.call(
'ldp.resource.get',
{
resourceUri: resourceUri,
accept: MIME_TYPES.JSON,
webId,
...rest
},
{ meta: { $cache: false } }
)
);
}
};

0 comments on commit f598f2d

Please sign in to comment.