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

Hydrated attributedTo property of Announce objects #16

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

allouis
Copy link
Collaborator

@allouis allouis commented Aug 1, 2024

This is needed to render the original author of the object in the frontend

This is needed to render the original author of the object in the frontend
@allouis allouis merged commit bcc14f3 into main Aug 1, 2024
1 check passed
@allouis allouis deleted the hydrated-announce branch August 1, 2024 09:46
Comment on lines 195 to +203
const objectJson = await object.toJsonLd();

if (typeof objectJson === 'object' && objectJson !== null) {
if ('attributedTo' in objectJson && typeof objectJson.attributedTo === 'string') {
const actor = await ctx.data.globaldb.get([objectJson.attributedTo]) ?? await lookupObject(objectJson.attributedTo)
objectJson.attributedTo = await (actor as any)?.toJsonLd();
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can be simplified:

await object.getAttribution({
  async documentLoader(url: string) {
    return await ctx.data.globaldb.get(url) ?? await ctx.documentLoader(url);
  }
});
const objectJson = await object.toJsonLd();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants