@@ -148,11 +148,8 @@ public static function buildForComment(Profile $actor, Comment $comment): array
148148 $ activityId = $ comment ->getObjectUrl ('/activity ' );
149149 $ commentObject = self ::buildCommentObject ($ actor , $ comment );
150150
151- return [
152- '@context ' => [
153- 'https://www.w3.org/ns/activitystreams ' ,
154- 'https://w3id.org/security/v1 ' ,
155- ],
151+ $ commentObj = [
152+ '@context ' => app (ActivityPubContext::class)->forComment ($ comment ),
156153 'id ' => $ activityId ,
157154 'type ' => 'Create ' ,
158155 'actor ' => $ actor ->getActorId (),
@@ -161,6 +158,12 @@ public static function buildForComment(Profile $actor, Comment $comment): array
161158 'cc ' => $ commentObject ['cc ' ],
162159 'object ' => $ commentObject ,
163160 ];
161+
162+ if ($ comment ->visibility === 1 ) {
163+ $ commentObj ['interactionPolicy ' ] = app (ActivityPubContext::class)->forCommentInteractionPolicy ($ comment );
164+ }
165+
166+ return $ commentObj ;
164167 }
165168
166169 /**
@@ -173,10 +176,7 @@ public static function buildForComment(Profile $actor, Comment $comment): array
173176 public static function buildForCommentFlat (Profile $ actor , Comment $ comment ): array
174177 {
175178 return [
176- '@context ' => [
177- 'https://www.w3.org/ns/activitystreams ' ,
178- 'https://w3id.org/security/v1 ' ,
179- ],
179+ '@context ' => app (ActivityPubContext::class)->forComment ($ comment ),
180180 ...self ::buildCommentObject ($ actor , $ comment ),
181181 ];
182182 }
@@ -204,6 +204,10 @@ private static function buildCommentObject(Profile $actor, Comment $comment): ar
204204 'cc ' => [],
205205 ];
206206
207+ if ($ comment ->visibility === 1 ) {
208+ $ commentObject ['interactionPolicy ' ] = app (ActivityPubContext::class)->forCommentInteractionPolicy ($ comment );
209+ }
210+
207211 $ mentions = [];
208212
209213 if ($ comment ->caption ) {
@@ -260,11 +264,8 @@ public static function buildForCommentReply(Profile $actor, CommentReply $commen
260264 $ activityId = $ comment ->getObjectUrl ('/activity ' );
261265 $ commentObject = self ::buildCommentReplyObject ($ actor , $ comment );
262266
263- return [
264- '@context ' => [
265- 'https://www.w3.org/ns/activitystreams ' ,
266- 'https://w3id.org/security/v1 ' ,
267- ],
267+ $ commentObj = [
268+ '@context ' => app (ActivityPubContext::class)->forCommentReply ($ comment ),
268269 'id ' => $ activityId ,
269270 'type ' => 'Create ' ,
270271 'actor ' => $ actor ->getActorId (),
@@ -273,6 +274,12 @@ public static function buildForCommentReply(Profile $actor, CommentReply $commen
273274 'cc ' => $ commentObject ['cc ' ],
274275 'object ' => $ commentObject ,
275276 ];
277+
278+ if ($ comment ->visibility === 1 ) {
279+ $ commentObj ['interactionPolicy ' ] = app (ActivityPubContext::class)->forCommentReplyInteractionPolicy ($ comment );
280+ }
281+
282+ return $ commentObj ;
276283 }
277284
278285 /**
@@ -298,6 +305,10 @@ private static function buildCommentReplyObject(Profile $actor, CommentReply $co
298305 'cc ' => [],
299306 ];
300307
308+ if ($ comment ->visibility === 1 ) {
309+ $ commentObject ['interactionPolicy ' ] = app (ActivityPubContext::class)->forCommentReplyInteractionPolicy ($ comment );
310+ }
311+
301312 $ mentions = [];
302313
303314 $ commentObject ['tag ' ] = [];
@@ -350,10 +361,7 @@ private static function buildCommentReplyObject(Profile $actor, CommentReply $co
350361 public static function buildForCommentReplyFlat (Profile $ actor , CommentReply $ comment ): array
351362 {
352363 return [
353- '@context ' => [
354- 'https://www.w3.org/ns/activitystreams ' ,
355- 'https://w3id.org/security/v1 ' ,
356- ],
364+ '@context ' => app (ActivityPubContext::class)->forCommentReply ($ comment ),
357365 ...self ::buildCommentReplyObject ($ actor , $ comment ),
358366 ];
359367 }
0 commit comments