@@ -73,6 +73,7 @@ const keyPair: CryptoKeyPair = {
73
73
privateKey : await importJwk ( {
74
74
kty : "RSA" ,
75
75
alg : "RS256" ,
76
+ // cSpell: disable
76
77
n : "15DAu9S9sROZ_NonfZm5S0PSeYuh2POeo0cpvvGnp_T9jQWjMuGdhwOPT7OOD9N-R1IY-2hXkk-RjfWNzbxMoNKvOpz_1MHRg18W5Lw60mIxZFztLKlNhOZS7rVrlJc--jj1wLETEfY5ocYCyRZm25UeT_Q1JSePdnhEGVXo4sSqoUcMV5Bgys5PlISfQj_bHDpcIi9snJ70hOzYTy7k7fNuCHHsK08DN4bZMG58qQNrPFtZW6fgpQiu0kgtUBFgQu-uUNn1h0io-7OhMU2dXeV8lwCILhIFRvrRV9vKQydBejbyYuzFY-Xq98biB9Aox8GD0jJE4tTVj6CpsmaN9yq6nI8ibWjnk87IKdU3jex5zB8chR0cm2tyIWr6dKhCTexmtYTF0pGW7PZ2Dnn31BU3cPkrkplu752D4eQ47BsAspMsHRxXE3NtqlmN02Y-6AIzt1tuPBPHldQHUpxtGrwFh9b9biC2mtb_w6F0oyxVyZsAZnuK2tN0-uX_iMPoC5VLnPrzgWjQiMArivg4u1cQ35hrvuFYFAdNf2WaBDyDNxaCoTD28z9bF1titlbQ48tDw0adZ1Zp8_x12JqA5HNpqDfmyT4KPU_6Ag7J7cGfGeO2vsjcc1oGhqZ-n6JlnSvVImHS5eKC6CDhW7ceuKC_oX-XPWWQQHhPniwM2RE" ,
77
78
e : "AQAB" ,
78
79
d : "eAD5ipdQUrfazcyUl3Nwl9nV3hxBqYlWEweW0dmtv-6_CDbPN5AqJfNxYKlQuLbAYevuRGc9-RGasjC1FIdzEUS4kCS-ty5--GeDUysGhABuBrVEw8wsf4PJP2J31WytfpcfGHp7Z1BvnQOioVd7Q1qsWU5WF60CTK1_G6ubzkI1yzrGQCj7-WsJGmEKV9M8o2ZJzC4ihL5o2WcQtGQixeTyqHjjROjjnZHQbwnTFDP3Cs6_3CqFANrol9_eeeh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AEqh3xyXscfsgzi0X6olBevJCGeTzOrqQX026JmNVykaS1-o_ea_Y0cD0q6Nxd5TwLZMCLZi1M5PLHhGlJg9MQ" ,
88
+ // cSpell: enable
87
89
key_ops : [ "sign" ] ,
88
90
ext : true ,
89
91
} , "private" ) ,
90
92
publicKey : await importJwk ( {
91
93
kty : "RSA" ,
92
94
alg : "RS256" ,
95
+ // cSpell: disable
93
96
n : "15DAu9S9sROZ_NonfZm5S0PSeYuh2POeo0cpvvGnp_T9jQWjMuGdhwOPT7OOD9N-R1IY-2hXkk-RjfWNzbxMoNKvOpz_1MHRg18W5Lw60mIxZFztLKlNhOZS7rVrlJc--jj1wLETEfY5ocYCyRZm25UeT_Q1JSePdnhEGVXo4sSqoUcMV5Bgys5PlISfQj_bHDpcIi9snJ70hOzYTy7k7fNuCHHsK08DN4bZMG58qQNrPFtZW6fgpQiu0kgtUBFgQu-uUNn1h0io-7OhMU2dXeV8lwCILhIFRvrRV9vKQydBejbyYuzFY-Xq98biB9Aox8GD0jJE4tTVj6CpsmaN9yq6nI8ibWjnk87IKdU3jex5zB8chR0cm2tyIWr6dKhCTexmtYTF0pGW7PZ2Dnn31BU3cPkrkplu752D4eQ47BsAspMsHRxXE3NtqlmN02Y-6AIzt1tuPBPHldQHUpxtGrwFh9b9biC2mtb_w6F0oyxVyZsAZnuK2tN0-uX_iMPoC5VLnPrzgWjQiMArivg4u1cQ35hrvuFYFAdNf2WaBDyDNxaCoTD28z9bF1titlbQ48tDw0adZ1Zp8_x12JqA5HNpqDfmyT4KPU_6Ag7J7cGfGeO2vsjcc1oGhqZ-n6JlnSvVImHS5eKC6CDhW7ceuKC_oX-XPWWQQHhPniwM2RE" ,
94
97
e : "AQAB" ,
98
+ // cSpell: enable
95
99
key_ops : [ "verify" ] ,
96
100
ext : true ,
97
101
} , "public" ) ,
98
102
} ;
99
103
100
- federation . setActorDispatcher ( "/ap/actor/{identifier}" , ( _ctx , identifier ) => {
104
+ federation . setActorDispatcher ( "/ap/actor/{identifier}" , ( ctx , identifier ) => {
101
105
return new Person ( {
106
+ id : ctx . getActorUri ( identifier ) ,
102
107
preferredUsername : identifier ,
103
108
} ) ;
104
109
} ) . setKeyPairsDispatcher ( ( _ctx , _identifier ) => {
@@ -117,6 +122,13 @@ const bot: BotWithVoidContextData = {
117
122
context : ctx ,
118
123
actorId : ctx . getActorUri ( bot . identifier ) ,
119
124
actorHandle : `@bot@${ ctx . host } ` as const ,
125
+ getActor ( ) {
126
+ const actor = new Person ( {
127
+ id : ctx . getActorUri ( bot . identifier ) ,
128
+ preferredUsername : "bot" ,
129
+ } ) ;
130
+ return Promise . resolve ( actor ) ;
131
+ } ,
120
132
publish ( _content : unknown , _options : unknown ) {
121
133
throw new Error ( "Not implemented" ) ;
122
134
} ,
@@ -366,6 +378,83 @@ Deno.test({
366
378
assertEquals ( cache5 . length , 1 ) ;
367
379
assertInstanceOf ( cache5 [ 0 ] , Person ) ;
368
380
assertEquals ( cache5 [ 0 ] . id , new URL ( "https://hollo.social/@fedify" ) ) ;
381
+
382
+ const m6 : Text < "inline" , void > = mention ( "@bot@example.com" ) ;
383
+ assertEquals (
384
+ ( await Array . fromAsync ( m6 . getHtml ( session ) ) ) . join ( "" ) ,
385
+ '<a href="https://example.com/ap/actor/bot" translate="no" ' +
386
+ 'class="h-card u-url mention" target="_blank">@<span>' +
387
+ "bot@example.com</span></a>" ,
388
+ ) ;
389
+ const tags6 = await Array . fromAsync ( m6 . getTags ( session ) ) ;
390
+ assertEquals ( tags6 . length , 1 ) ;
391
+ assertInstanceOf ( tags6 [ 0 ] , Mention ) ;
392
+ assertEquals ( tags6 [ 0 ] . name , "@bot@example.com" ) ;
393
+ assertEquals ( tags6 [ 0 ] . href , new URL ( "https://example.com/ap/actor/bot" ) ) ;
394
+ const cache6 = m6 . getCachedObjects ( ) ;
395
+ assertEquals ( cache6 . length , 1 ) ;
396
+ assertInstanceOf ( cache6 [ 0 ] , Person ) ;
397
+ assertEquals ( cache6 [ 0 ] . id , new URL ( "https://example.com/ap/actor/bot" ) ) ;
398
+
399
+ const m7 : Text < "inline" , void > = mention (
400
+ "Example" ,
401
+ new URL ( "https://example.com/ap/actor/bot" ) ,
402
+ ) ;
403
+ assertEquals (
404
+ ( await Array . fromAsync ( m7 . getHtml ( session ) ) ) . join ( "" ) ,
405
+ '<a href="https://example.com/ap/actor/bot" translate="no" ' +
406
+ 'class="h-card u-url mention" target="_blank">Example</a>' ,
407
+ ) ;
408
+ const tags7 = await Array . fromAsync ( m7 . getTags ( session ) ) ;
409
+ assertEquals ( tags7 . length , 1 ) ;
410
+ assertInstanceOf ( tags7 [ 0 ] , Mention ) ;
411
+ assertEquals ( tags7 [ 0 ] . name , "Example" ) ;
412
+ assertEquals ( tags7 [ 0 ] . href , new URL ( "https://example.com/ap/actor/bot" ) ) ;
413
+ const cache7 = m7 . getCachedObjects ( ) ;
414
+ assertEquals ( cache7 . length , 1 ) ;
415
+ assertInstanceOf ( cache7 [ 0 ] , Person ) ;
416
+ assertEquals ( cache7 [ 0 ] . id , new URL ( "https://example.com/ap/actor/bot" ) ) ;
417
+
418
+ const m8 : Text < "inline" , void > = mention (
419
+ new Person ( {
420
+ id : new URL ( "https://example.com/ap/actor/bot" ) ,
421
+ preferredUsername : "bot" ,
422
+ } ) ,
423
+ ) ;
424
+ assertEquals (
425
+ ( await Array . fromAsync ( m8 . getHtml ( session ) ) ) . join ( "" ) ,
426
+ '<a href="https://example.com/ap/actor/bot" translate="no" ' +
427
+ 'class="h-card u-url mention" target="_blank">@<span>' +
428
+ "bot@example.com</span></a>" ,
429
+ ) ;
430
+ const tags8 = await Array . fromAsync ( m8 . getTags ( session ) ) ;
431
+ assertEquals ( tags8 . length , 1 ) ;
432
+ assertInstanceOf ( tags8 [ 0 ] , Mention ) ;
433
+ assertEquals ( tags8 [ 0 ] . name , "@bot@example.com" ) ;
434
+ assertEquals ( tags8 [ 0 ] . href , new URL ( "https://example.com/ap/actor/bot" ) ) ;
435
+ const cache8 = m8 . getCachedObjects ( ) ;
436
+ assertEquals ( cache8 . length , 1 ) ;
437
+ assertInstanceOf ( cache8 [ 0 ] , Person ) ;
438
+ assertEquals ( cache8 [ 0 ] . id , new URL ( "https://example.com/ap/actor/bot" ) ) ;
439
+
440
+ const m9 : Text < "inline" , void > = mention (
441
+ new URL ( "https://example.com/ap/actor/bot" ) ,
442
+ ) ;
443
+ assertEquals (
444
+ ( await Array . fromAsync ( m9 . getHtml ( session ) ) ) . join ( "" ) ,
445
+ '<a href="https://example.com/ap/actor/bot" translate="no" ' +
446
+ 'class="h-card u-url mention" target="_blank">@<span>' +
447
+ "bot@example.com</span></a>" ,
448
+ ) ;
449
+ const tags9 = await Array . fromAsync ( m9 . getTags ( session ) ) ;
450
+ assertEquals ( tags9 . length , 1 ) ;
451
+ assertInstanceOf ( tags9 [ 0 ] , Mention ) ;
452
+ assertEquals ( tags9 [ 0 ] . name , "@bot@example.com" ) ;
453
+ assertEquals ( tags9 [ 0 ] . href , new URL ( "https://example.com/ap/actor/bot" ) ) ;
454
+ const cache9 = m9 . getCachedObjects ( ) ;
455
+ assertEquals ( cache9 . length , 1 ) ;
456
+ assertInstanceOf ( cache9 [ 0 ] , Person ) ;
457
+ assertEquals ( cache9 [ 0 ] . id , new URL ( "https://example.com/ap/actor/bot" ) ) ;
369
458
} ,
370
459
} ) ;
371
460
@@ -477,4 +566,21 @@ Deno.test("markdown()", async () => {
477
566
) ;
478
567
assertEquals ( await Array . fromAsync ( t2 . getTags ( session ) ) , [ ] ) ;
479
568
assertEquals ( t2 . getCachedObjects ( ) , [ ] ) ;
569
+
570
+ const t3 : Text < "block" , void > = markdown ( "@bot@example.com" ) ;
571
+ assertEquals (
572
+ ( await Array . fromAsync ( t3 . getHtml ( session ) ) ) . join ( "" ) ,
573
+ '<p><a translate="no" class="h-card u-url mention" target="_blank" href="https://example.com/ap/actor/bot">' +
574
+ '<span class="at">@</span><span class="user">bot</span>' +
575
+ '<span class="at">@</span><span class="domain">example.com</span></a></p>\n' ,
576
+ ) ;
577
+ const tags3 = await Array . fromAsync ( t3 . getTags ( session ) ) ;
578
+ assertEquals ( tags3 . length , 1 ) ;
579
+ assertInstanceOf ( tags3 [ 0 ] , Mention ) ;
580
+ assertEquals ( tags3 [ 0 ] . name , "@bot@example.com" ) ;
581
+ assertEquals ( tags3 [ 0 ] . href , new URL ( "https://example.com/ap/actor/bot" ) ) ;
582
+ const cache3 = t3 . getCachedObjects ( ) ;
583
+ assertEquals ( cache3 . length , 1 ) ;
584
+ assertInstanceOf ( cache3 [ 0 ] , Person ) ;
585
+ assertEquals ( cache3 [ 0 ] . id , new URL ( "https://example.com/ap/actor/bot" ) ) ;
480
586
} ) ;
0 commit comments