Merge pull request #3464 from pixelfed/ld

Fix JSON-LD contexts
This commit is contained in:
daniel 2022-05-15 21:54:40 -06:00 committed by GitHub
commit 2205307671
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 89 deletions

View file

@ -8,6 +8,7 @@
- Add storage flags to admin dashboard diagnostics ([#3444](https://github.com/pixelfed/pixelfed/pull/3444)) - Add storage flags to admin dashboard diagnostics ([#3444](https://github.com/pixelfed/pixelfed/pull/3444))
- Hardcode UTC application timezone to prevent timezone issues ([b0d2c5e1](https://github.com/pixelfed/pixelfed/commit/b0d2c5e1)) - Hardcode UTC application timezone to prevent timezone issues ([b0d2c5e1](https://github.com/pixelfed/pixelfed/commit/b0d2c5e1))
- Remove arbitrary metro url redirect timeout ([84209c24](https://github.com/pixelfed/pixelfed/commit/84209c24)) - Remove arbitrary metro url redirect timeout ([84209c24](https://github.com/pixelfed/pixelfed/commit/84209c24))
- Fix JSON-LD contexts ([#3464](https://github.com/pixelfed/pixelfed/pull/3464))
- Fix json-ld attributes, fixes #3423 ([95f902b1](https://github.com/pixelfed/pixelfed/commit/95f902b1)) - Fix json-ld attributes, fixes #3423 ([95f902b1](https://github.com/pixelfed/pixelfed/commit/95f902b1))
- Add trusted proxies flag to admin dashboard diagnostics ([#3450](https://github.com/pixelfed/pixelfed/pull/3450)) - Add trusted proxies flag to admin dashboard diagnostics ([#3450](https://github.com/pixelfed/pixelfed/pull/3450))
- Fix json-ld attributes, fixes #3423 ([95f902b1](https://github.com/pixelfed/pixelfed/commit/95f902b1)) - Fix json-ld attributes, fixes #3423 ([95f902b1](https://github.com/pixelfed/pixelfed/commit/95f902b1))

View file

@ -796,13 +796,8 @@ class DirectMessageController extends Controller
$body = [ $body = [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
[ 'https://www.w3.org/ns/activitystreams',
'sc' => 'http://schema.org#',
'Hashtag' => 'as:Hashtag',
'sensitive' => 'as:sensitive',
]
], ],
'id' => $dm->status->permalink(), 'id' => $dm->status->permalink(),
'type' => 'Create', 'type' => 'Create',
@ -845,12 +840,6 @@ class DirectMessageController extends Controller
$body = [ $body = [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
'sc' => 'http://schema.org#',
'Hashtag' => 'as:Hashtag',
'sensitive' => 'as:sensitive',
]
], ],
'id' => $dm->status->permalink('#delete'), 'id' => $dm->status->permalink('#delete'),
'to' => [ 'to' => [

View file

@ -11,13 +11,10 @@ class ProfileTransformer extends Fractal\TransformerAbstract
{ {
return [ return [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
'https://www.w3.org/ns/activitystreams',
[ [
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
'PropertyValue' => 'schema:PropertyValue',
'schema' => 'http://schema.org#',
'value' => 'schema:value'
], ],
], ],
'id' => $profile->permalink(), 'id' => $profile->permalink(),

View file

@ -53,17 +53,32 @@ class CreateNote extends Fractal\TransformerAbstract
return [ return [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
'https://www.w3.org/ns/activitystreams',
[ [
'sc' => 'http://schema.org#',
'Hashtag' => 'as:Hashtag', 'Hashtag' => 'as:Hashtag',
'sensitive' => 'as:sensitive', 'sensitive' => 'as:sensitive',
'commentsEnabled' => 'sc:Boolean', 'schema' => 'http://schema.org/',
'@capabilities' => [ 'pixelfed' => 'http://pixelfed.org/ns#'
'@announce' => '@id', 'commentsEnabled' => [
'@like' => '@id', '@id' => 'pixelfed:commentsEnabled',
'@reply' => '@id', '@type' => 'schema:Boolean'
],
'capabilities' => [
'@id' => 'pixelfed:capabilities',
'@container' => '@set'
],
'announce' => [
'@id' => 'pixelfed:canAnnounce',
'@type' => '@id'
],
'like' => [
'@id' => 'pixelfed:canLike',
'@type' => '@id'
],
'reply' => [
'@id' => 'pixelfed:canReply',
'@type' => '@id'
], ],
'toot' => 'http://joinmastodon.org/ns#', 'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji' 'Emoji' => 'toot:Emoji'

View file

@ -16,18 +16,35 @@ class CreateQuestion extends Fractal\TransformerAbstract
{ {
return [ return [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
'https://www.w3.org/ns/activitystreams',
[ [
'sc' => 'http://schema.org#',
'Hashtag' => 'as:Hashtag', 'Hashtag' => 'as:Hashtag',
'sensitive' => 'as:sensitive', 'sensitive' => 'as:sensitive',
'commentsEnabled' => 'sc:Boolean', 'schema' => 'http://schema.org/',
'@capabilities' => [ 'pixelfed' => 'http://pixelfed.org/ns#'
'@announce' => '@id', 'commentsEnabled' => [
'@like' => '@id', '@id' => 'pixelfed:commentsEnabled',
'@reply' => '@id', '@type' => 'schema:Boolean'
], ],
'capabilities' => [
'@id' => 'pixelfed:capabilities',
'@container' => '@set'
],
'announce' => [
'@id' => 'pixelfed:canAnnounce',
'@type' => '@id'
],
'like' => [
'@id' => 'pixelfed:canLike',
'@type' => '@id'
],
'reply' => [
'@id' => 'pixelfed:canReply',
'@type' => '@id'
],
'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji'
] ]
], ],
'id' => $status->permalink(), 'id' => $status->permalink(),

View file

@ -54,17 +54,32 @@ class Note extends Fractal\TransformerAbstract
return [ return [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
'https://www.w3.org/ns/activitystreams',
[ [
'sc' => 'http://schema.org#',
'Hashtag' => 'as:Hashtag', 'Hashtag' => 'as:Hashtag',
'sensitive' => 'as:sensitive', 'sensitive' => 'as:sensitive',
'commentsEnabled' => 'sc:Boolean', 'schema' => 'http://schema.org/',
'@capabilities' => [ 'pixelfed' => 'http://pixelfed.org/ns#'
'@announce' => '@id', 'commentsEnabled' => [
'@like' => '@id', '@id' => 'pixelfed:commentsEnabled',
'@reply' => '@id', '@type' => 'schema:Boolean'
],
'capabilities' => [
'@id' => 'pixelfed:capabilities',
'@container' => '@set'
],
'announce' => [
'@id' => 'pixelfed:canAnnounce',
'@type' => '@id'
],
'like' => [
'@id' => 'pixelfed:canLike',
'@type' => '@id'
],
'reply' => [
'@id' => 'pixelfed:canReply',
'@type' => '@id'
], ],
'toot' => 'http://joinmastodon.org/ns#', 'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji' 'Emoji' => 'toot:Emoji'

View file

@ -32,58 +32,75 @@ class Question extends Fractal\TransformerAbstract
$tags = array_merge($mentions, $hashtags); $tags = array_merge($mentions, $hashtags);
return [ return [
'@context' => [ '@context' => [
'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1',
'https://w3id.org/security/v1', 'https://www.w3.org/ns/activitystreams',
[ [
'sc' => 'http://schema.org#', 'Hashtag' => 'as:Hashtag',
'Hashtag' => 'as:Hashtag', 'sensitive' => 'as:sensitive',
'sensitive' => 'as:sensitive', 'schema' => 'http://schema.org/',
'commentsEnabled' => 'sc:Boolean', 'pixelfed' => 'http://pixelfed.org/ns#'
'@capabilities' => [ 'commentsEnabled' => [
'@announce' => '@id', '@id' => 'pixelfed:commentsEnabled',
'@like' => '@id', '@type' => 'schema:Boolean'
'@reply' => '@id', ],
], 'capabilities' => [
'@id' => 'pixelfed:capabilities',
'@container' => '@set'
],
'announce' => [
'@id' => 'pixelfed:canAnnounce',
'@type' => '@id'
],
'like' => [
'@id' => 'pixelfed:canLike',
'@type' => '@id'
],
'reply' => [
'@id' => 'pixelfed:canReply',
'@type' => '@id'
],
'toot' => 'http://joinmastodon.org/ns#',
'Emoji' => 'toot:Emoji'
]
],
'id' => $status->url(),
'type' => 'Question',
'summary' => null,
'content' => $status->rendered ?? $status->caption,
'inReplyTo' => $status->in_reply_to_id ? $status->parent()->url() : null,
'published' => $status->created_at->toAtomString(),
'url' => $status->url(),
'attributedTo' => $status->profile->permalink(),
'to' => $status->scopeToAudience('to'),
'cc' => $status->scopeToAudience('cc'),
'sensitive' => (bool) $status->is_nsfw,
'attachment' => [],
'tag' => $tags,
'commentsEnabled' => (bool) !$status->comments_disabled,
'capabilities' => [
'announce' => 'https://www.w3.org/ns/activitystreams#Public',
'like' => 'https://www.w3.org/ns/activitystreams#Public',
'reply' => $status->comments_disabled == true ? null : 'https://www.w3.org/ns/activitystreams#Public'
],
'location' => $status->place_id ? [
'type' => 'Place',
'name' => $status->place->name,
'longitude' => $status->place->long,
'latitude' => $status->place->lat,
'country' => $status->place->country
] : null,
'endTime' => $status->poll->expires_at->toAtomString(),
'oneOf' => collect($status->poll->poll_options)->map(function($option, $index) use($status) {
return [
'type' => 'Note',
'name' => $option,
'replies' => [
'type' => 'Collection',
'totalItems' => $status->poll->cached_tallies[$index]
] ]
], ];
'id' => $status->url(), })
'type' => 'Question', ];
'summary' => null,
'content' => $status->rendered ?? $status->caption,
'inReplyTo' => $status->in_reply_to_id ? $status->parent()->url() : null,
'published' => $status->created_at->toAtomString(),
'url' => $status->url(),
'attributedTo' => $status->profile->permalink(),
'to' => $status->scopeToAudience('to'),
'cc' => $status->scopeToAudience('cc'),
'sensitive' => (bool) $status->is_nsfw,
'attachment' => [],
'tag' => $tags,
'commentsEnabled' => (bool) !$status->comments_disabled,
'capabilities' => [
'announce' => 'https://www.w3.org/ns/activitystreams#Public',
'like' => 'https://www.w3.org/ns/activitystreams#Public',
'reply' => $status->comments_disabled == true ? null : 'https://www.w3.org/ns/activitystreams#Public'
],
'location' => $status->place_id ? [
'type' => 'Place',
'name' => $status->place->name,
'longitude' => $status->place->long,
'latitude' => $status->place->lat,
'country' => $status->place->country
] : null,
'endTime' => $status->poll->expires_at->toAtomString(),
'oneOf' => collect($status->poll->poll_options)->map(function($option, $index) use($status) {
return [
'type' => 'Note',
'name' => $option,
'replies' => [
'type' => 'Collection',
'totalItems' => $status->poll->cached_tallies[$index]
]
];
})
];
} }
} }