Skip to content

Commit d227f4e

Browse files
committed
Make posts and comments with a poll being AP type 'Question'
- if an object contains a poll, it needs to be of type 'Question' in the AP representation - update the testing snapshots - scrub the URL from `Question` object snapshots as well
1 parent 29d6baf commit d227f4e

14 files changed

Lines changed: 15 additions & 15 deletions

src/Factory/ActivityPub/EntryCommentNoteFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function create(EntryComment $comment, array $tags, bool $context = false
5252

5353
$note = array_merge($note ?? [], [
5454
'id' => $this->getActivityPubId($comment),
55-
'type' => 'Note',
55+
'type' => $comment->poll ? 'Question' : 'Note',
5656
'attributedTo' => $this->activityPubManager->getActorProfileId($comment->user),
5757
'inReplyTo' => $this->getReplyTo($comment),
5858
'to' => [

src/Factory/ActivityPub/PostCommentNoteFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function create(PostComment $comment, array $tags, bool $context = false)
5252

5353
$note = array_merge($note ?? [], [
5454
'id' => $this->getActivityPubId($comment),
55-
'type' => 'Note',
55+
'type' => $comment->poll ? 'Question' : 'Note',
5656
'attributedTo' => $this->activityPubManager->getActorProfileId($comment->user),
5757
'inReplyTo' => $this->getReplyTo($comment),
5858
'to' => [

src/Factory/ActivityPub/PostNoteFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function create(Post $post, array $tags, bool $context = false): array
5858

5959
$note = array_merge($note ?? [], [
6060
'id' => $this->getActivityPubId($post),
61-
'type' => 'Note',
61+
'type' => $post->poll ? 'Question' : 'Note',
6262
'attributedTo' => $this->activityPubManager->getActorProfileId($post->user),
6363
'inReplyTo' => null,
6464
'to' => [

tests/ActivityPubJsonDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function scrubArray(array $data): array
5454
$data['id'] = 'SCRUBBED_ID';
5555
}
5656

57-
if (isset($data['type']) && 'Note' === $data['type'] && isset($data['url'])) {
57+
if (isset($data['type']) && ('Note' === $data['type'] || 'Question' === $data['type']) && isset($data['url'])) {
5858
$data['url'] = 'SCRUBBED_ID';
5959
}
6060

@@ -103,7 +103,7 @@ protected function scrubObject(object $data): object
103103
$data->id = 'SCRUBBED_ID';
104104
}
105105

106-
if (isset($data->type) && 'Note' === $data->type && isset($data->url)) {
106+
if (isset($data->type) && ('Note' === $data->type || 'Question' === $data->type) && isset($data->url)) {
107107
$data->url = 'SCRUBBED_ID';
108108
}
109109

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateEntryCommentWithMultipleChoicePoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateEntryCommentWithPoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateNestedEntryCommentWithMultipleChoicePoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateNestedEntryCommentWithPoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateNestedPostCommentWithMultipleChoicePoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

tests/Unit/ActivityPub/Outbox/JsonSnapshots/CreateTest__testCreateNestedPostCommentWithPoll__1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"object": {
2020
"id": "SCRUBBED_ID",
21-
"type": "Note",
21+
"type": "Question",
2222
"attributedTo": "https://kbin.test/u/user",
2323
"inReplyTo": "SCRUBBED_ID",
2424
"to": [

0 commit comments

Comments
 (0)