Skip to content

Commit

Permalink
fix(backend): Accept arrays in ActivityPub icon and image propert…
Browse files Browse the repository at this point in the history
…ies (#14825)

This is allowed according to the Activity vocabulary: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-icon
The issue is noticeable in combination with Bridgy Fed: snarfed/bridgy-fed#1408
  • Loading branch information
Tamschi authored Oct 28, 2024
1 parent 0472d43 commit 8eb7749
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export class ApPersonService implements OnModuleInit {
if (user == null) throw new Error('failed to create user: user is null');

const [avatar, banner] = await Promise.all([icon, image].map(img => {
// icon and image may be arrays
// see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-icon
if (Array.isArray(img)) {
img = img.find(item => item && item.url) ?? null;
}

// if we have an explicitly missing image, return an
// explicitly-null set of values
if ((img == null) || (typeof img === 'object' && img.url == null)) {
Expand Down

0 comments on commit 8eb7749

Please sign in to comment.