@@ -45,44 +45,93 @@ test("getSharedChannelIds: includes only active joined channels", () => {
4545 ) ;
4646} ) ;
4747
48- test ( "relayAgentIsSharedWithUser: requires anyone response and a shared channel " , ( ) => {
48+ test ( "relayAgentIsSharedWithUser: accepts shared anyone agents and rejects unshared ones " , ( ) => {
4949 const sharedChannelIds = new Set ( [ "general" ] ) ;
5050
5151 assert . equal (
5252 relayAgentIsSharedWithUser (
53- { respondTo : "anyone" , channelIds : [ "general" ] } ,
53+ { respondTo : "anyone" , respondToAllowlist : [ ] , channelIds : [ "general" ] } ,
5454 sharedChannelIds ,
5555 ) ,
5656 true ,
5757 ) ;
5858 assert . equal (
5959 relayAgentIsSharedWithUser (
60- { respondTo : "owner-only" , channelIds : [ "general" ] } ,
60+ {
61+ respondTo : "owner-only" ,
62+ respondToAllowlist : [ ] ,
63+ channelIds : [ "general" ] ,
64+ } ,
6165 sharedChannelIds ,
6266 ) ,
6367 false ,
6468 ) ;
6569 assert . equal (
6670 relayAgentIsSharedWithUser (
67- { respondTo : "anyone" , channelIds : [ "other" ] } ,
71+ { respondTo : "anyone" , respondToAllowlist : [ ] , channelIds : [ "other" ] } ,
6872 sharedChannelIds ,
6973 ) ,
7074 false ,
7175 ) ;
7276} ) ;
7377
78+ test ( "relayAgentIsSharedWithUser: accepts allowlist agents for the current user" , ( ) => {
79+ const sharedChannelIds = new Set ( [ "general" ] ) ;
80+
81+ assert . equal (
82+ relayAgentIsSharedWithUser (
83+ {
84+ respondTo : "allowlist" ,
85+ respondToAllowlist : [ OTHER_OWNER_PUBKEY , CURRENT_PUBKEY . toUpperCase ( ) ] ,
86+ channelIds : [ "other" ] ,
87+ } ,
88+ sharedChannelIds ,
89+ CURRENT_PUBKEY ,
90+ ) ,
91+ true ,
92+ ) ;
93+ assert . equal (
94+ relayAgentIsSharedWithUser (
95+ {
96+ respondTo : "allowlist" ,
97+ respondToAllowlist : [ OTHER_OWNER_PUBKEY ] ,
98+ channelIds : [ "general" ] ,
99+ } ,
100+ sharedChannelIds ,
101+ CURRENT_PUBKEY ,
102+ ) ,
103+ false ,
104+ ) ;
105+ } ) ;
106+
74107test ( "getMentionableAgentPubkeys: keeps managed agents and shared relay agents" , ( ) => {
75108 const result = getMentionableAgentPubkeys ( {
76109 managedAgentPubkeys : [ PUB_A ] ,
110+ currentPubkey : CURRENT_PUBKEY ,
77111 relayAgents : [
78- { pubkey : PUB_B , respondTo : "anyone" , channelIds : [ "general" ] } ,
79- { pubkey : PUB_C , respondTo : "owner-only" , channelIds : [ "general" ] } ,
80- { pubkey : PUB_D , respondTo : "anyone" , channelIds : [ "other" ] } ,
112+ {
113+ pubkey : PUB_B ,
114+ respondTo : "anyone" ,
115+ respondToAllowlist : [ ] ,
116+ channelIds : [ "general" ] ,
117+ } ,
118+ {
119+ pubkey : PUB_C ,
120+ respondTo : "allowlist" ,
121+ respondToAllowlist : [ CURRENT_PUBKEY ] ,
122+ channelIds : [ "other" ] ,
123+ } ,
124+ {
125+ pubkey : PUB_D ,
126+ respondTo : "anyone" ,
127+ respondToAllowlist : [ ] ,
128+ channelIds : [ "other" ] ,
129+ } ,
81130 ] ,
82131 sharedChannelIds : new Set ( [ "general" ] ) ,
83132 } ) ;
84133
85- assert . deepEqual ( result , new Set ( [ PUB_A , PUB_B ] ) ) ;
134+ assert . deepEqual ( result , new Set ( [ PUB_A , PUB_B , PUB_C ] ) ) ;
86135} ) ;
87136
88137test ( "coalesceAgentAutocompleteCandidates: merges agents with the same persona id" , ( ) => {
0 commit comments