@@ -2309,6 +2309,137 @@ test("BotImpl.fetch()", async () => {
23092309 assert . deepStrictEqual ( response2 . status , 200 ) ;
23102310} ) ;
23112311
2312+ test ( "BotImpl.fetch() includes FEP-5711 inverse properties" , async ( ) => {
2313+ const repository = new MemoryRepository ( ) ;
2314+ const bot = new BotImpl < void > ( {
2315+ kv : new MemoryKvStore ( ) ,
2316+ repository,
2317+ username : "bot" ,
2318+ collectionWindow : 1 ,
2319+ } ) ;
2320+ const actorId = new URL ( "https://example.com/ap/actor/bot" ) ;
2321+
2322+ await repository . addFollower (
2323+ new URL ( "https://example.com/actor/1#follow" ) ,
2324+ new Person ( {
2325+ id : new URL ( "https://example.com/actor/1" ) ,
2326+ preferredUsername : "john" ,
2327+ inbox : new URL ( "https://example.com/actor/1/inbox" ) ,
2328+ } ) ,
2329+ ) ;
2330+ await repository . addMessage (
2331+ "78acb1ea-4ac6-46b7-bcd4-3a8965d8126e" ,
2332+ new Create ( {
2333+ id : new URL (
2334+ "https://example.com/ap/actor/bot/create/78acb1ea-4ac6-46b7-bcd4-3a8965d8126e" ,
2335+ ) ,
2336+ actor : actorId ,
2337+ to : PUBLIC_COLLECTION ,
2338+ cc : new URL ( "https://example.com/ap/actor/bot/followers" ) ,
2339+ object : new Note ( {
2340+ id : new URL ( "https://example.com/ap/actor/bot/note/1" ) ,
2341+ attribution : actorId ,
2342+ to : PUBLIC_COLLECTION ,
2343+ cc : new URL ( "https://example.com/ap/actor/bot/followers" ) ,
2344+ content : "Hello, world!" ,
2345+ published : Temporal . Instant . from ( "2025-01-01T00:00:00Z" ) ,
2346+ } ) ,
2347+ published : Temporal . Instant . from ( "2025-01-01T00:00:00Z" ) ,
2348+ } ) ,
2349+ ) ;
2350+
2351+ const actorResponse = await bot . fetch (
2352+ new Request ( "https://example.com/ap/actor/bot" , {
2353+ headers : { accept : "application/activity+json" } ,
2354+ } ) ,
2355+ ) ;
2356+ assert . deepStrictEqual ( actorResponse . status , 200 ) ;
2357+ const actorJson = await actorResponse . json ( ) ;
2358+ assert . deepStrictEqual ( actorJson . id , actorId . href ) ;
2359+ assert . deepStrictEqual (
2360+ actorJson . followers ,
2361+ "https://example.com/ap/actor/bot/followers" ,
2362+ ) ;
2363+ assert . deepStrictEqual (
2364+ actorJson . outbox ,
2365+ "https://example.com/ap/actor/bot/outbox" ,
2366+ ) ;
2367+
2368+ const outboxResponse = await bot . fetch (
2369+ new Request ( "https://example.com/ap/actor/bot/outbox" , {
2370+ headers : { accept : "application/activity+json" } ,
2371+ } ) ,
2372+ ) ;
2373+ assert . deepStrictEqual ( outboxResponse . status , 200 ) ;
2374+ const outboxJson = await outboxResponse . json ( ) ;
2375+ assert . deepStrictEqual ( outboxJson . type , "OrderedCollection" ) ;
2376+ assert . deepStrictEqual (
2377+ outboxJson . id ,
2378+ "https://example.com/ap/actor/bot/outbox" ,
2379+ ) ;
2380+ assert . deepStrictEqual ( outboxJson . totalItems , 1 ) ;
2381+ assert . deepStrictEqual (
2382+ outboxJson . first ,
2383+ "https://example.com/ap/actor/bot/outbox?cursor=" ,
2384+ ) ;
2385+ assert . deepStrictEqual ( outboxJson . outboxOf , actorId . href ) ;
2386+
2387+ const outboxPageResponse = await bot . fetch (
2388+ new Request ( "https://example.com/ap/actor/bot/outbox?cursor=" , {
2389+ headers : { accept : "application/activity+json" } ,
2390+ } ) ,
2391+ ) ;
2392+ assert . deepStrictEqual ( outboxPageResponse . status , 200 ) ;
2393+ const outboxPageJson = await outboxPageResponse . json ( ) ;
2394+ assert . deepStrictEqual ( outboxPageJson . type , "OrderedCollectionPage" ) ;
2395+ assert . deepStrictEqual (
2396+ outboxPageJson . id ,
2397+ "https://example.com/ap/actor/bot/outbox?cursor=" ,
2398+ ) ;
2399+ assert . deepStrictEqual (
2400+ outboxPageJson . partOf ,
2401+ "https://example.com/ap/actor/bot/outbox" ,
2402+ ) ;
2403+ assert . deepStrictEqual ( outboxPageJson . outboxOf , actorId . href ) ;
2404+
2405+ const followersResponse = await bot . fetch (
2406+ new Request ( "https://example.com/ap/actor/bot/followers" , {
2407+ headers : { accept : "application/activity+json" } ,
2408+ } ) ,
2409+ ) ;
2410+ assert . deepStrictEqual ( followersResponse . status , 200 ) ;
2411+ const followersJson = await followersResponse . json ( ) ;
2412+ assert . deepStrictEqual ( followersJson . type , "OrderedCollection" ) ;
2413+ assert . deepStrictEqual (
2414+ followersJson . id ,
2415+ "https://example.com/ap/actor/bot/followers" ,
2416+ ) ;
2417+ assert . deepStrictEqual ( followersJson . totalItems , 1 ) ;
2418+ assert . deepStrictEqual (
2419+ followersJson . first ,
2420+ "https://example.com/ap/actor/bot/followers?cursor=0" ,
2421+ ) ;
2422+ assert . deepStrictEqual ( followersJson . followersOf , actorId . href ) ;
2423+
2424+ const followersPageResponse = await bot . fetch (
2425+ new Request ( "https://example.com/ap/actor/bot/followers?cursor=0" , {
2426+ headers : { accept : "application/activity+json" } ,
2427+ } ) ,
2428+ ) ;
2429+ assert . deepStrictEqual ( followersPageResponse . status , 200 ) ;
2430+ const followersPageJson = await followersPageResponse . json ( ) ;
2431+ assert . deepStrictEqual ( followersPageJson . type , "OrderedCollectionPage" ) ;
2432+ assert . deepStrictEqual (
2433+ followersPageJson . id ,
2434+ "https://example.com/ap/actor/bot/followers?cursor=0" ,
2435+ ) ;
2436+ assert . deepStrictEqual (
2437+ followersPageJson . partOf ,
2438+ "https://example.com/ap/actor/bot/followers" ,
2439+ ) ;
2440+ assert . deepStrictEqual ( followersPageJson . followersOf , actorId . href ) ;
2441+ } ) ;
2442+
23122443describe ( "BotImpl.addCustomEmoji(), BotImpl.addCustomEmojis()" , ( ) => {
23132444 const bot = new BotImpl < void > ( { kv : new MemoryKvStore ( ) , username : "bot" } ) ;
23142445
0 commit comments