@@ -135,6 +135,61 @@ describe('resources', function () {
135135 expect ( res . get ( 'content-type' ) ?. includes ( 'application/ld+json' ) ) . toBeTrue ( )
136136 expect ( res . body ) . toEqual ( standard )
137137 } )
138+ it ( 'handles fully qualified activitypub mime' , async function ( ) {
139+ const oid = apex . utils . objectIdToIRI ( )
140+ let obj = {
141+ id : oid ,
142+ type : 'Note' ,
143+ content : 'Hello.' ,
144+ attributedTo : 'https://localhost/u/test' ,
145+ to : [ 'https://ignore.com/u/ignored' , apex . consts . publicAddress ]
146+ }
147+ obj = await apex . fromJSONLD ( obj )
148+ await apex . store . saveObject ( obj )
149+ const res = await request ( app )
150+ . get ( oid . replace ( 'https://localhost' , '' ) )
151+ . set ( 'Accept' , 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' )
152+ . expect ( 200 )
153+ const standard = {
154+ '@context' : [ 'https://www.w3.org/ns/activitystreams' , 'https://w3id.org/security/v1' ] ,
155+ id : oid ,
156+ type : 'Note' ,
157+ content : 'Hello.' ,
158+ attributedTo : 'https://localhost/u/test' ,
159+ to : [ 'https://ignore.com/u/ignored' , apex . consts . publicAddress ]
160+ }
161+ // don't match the whole string because express injects other params like charset
162+ expect ( res . get ( 'content-type' ) . includes ( 'application/ld+json' ) ) . toBeTrue ( )
163+ expect ( res . get ( 'content-type' ) . includes ( 'profile="https://www.w3.org/ns/activitystreams"' ) ) . toBeTrue ( )
164+ expect ( res . body ) . toEqual ( standard )
165+ } )
166+ it ( 'handles fully shorthand activitypub mime' , async function ( ) {
167+ const oid = apex . utils . objectIdToIRI ( )
168+ let obj = {
169+ id : oid ,
170+ type : 'Note' ,
171+ content : 'Hello.' ,
172+ attributedTo : 'https://localhost/u/test' ,
173+ to : [ 'https://ignore.com/u/ignored' , apex . consts . publicAddress ]
174+ }
175+ obj = await apex . fromJSONLD ( obj )
176+ await apex . store . saveObject ( obj )
177+ const res = await request ( app )
178+ . get ( oid . replace ( 'https://localhost' , '' ) )
179+ . set ( 'Accept' , 'application/activity+json' )
180+ . expect ( 200 )
181+ const standard = {
182+ '@context' : [ 'https://www.w3.org/ns/activitystreams' , 'https://w3id.org/security/v1' ] ,
183+ id : oid ,
184+ type : 'Note' ,
185+ content : 'Hello.' ,
186+ attributedTo : 'https://localhost/u/test' ,
187+ to : [ 'https://ignore.com/u/ignored' , apex . consts . publicAddress ]
188+ }
189+ // don't match the whole string because express injects other params like charset
190+ expect ( res . get ( 'content-type' ) . includes ( 'application/activity+json' ) ) . toBeTrue ( )
191+ expect ( res . body ) . toEqual ( standard )
192+ } )
138193 } )
139194 describe ( 'get activity' , function ( ) {
140195 it ( 'returns public activity' , async function ( ) {
0 commit comments