@@ -301,7 +301,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
301301 `[tlon] Using autoDiscoverChannels from settings store: ${ effectiveAutoDiscoverChannels } ` ,
302302 ) ;
303303 }
304- if ( currentSettings . dmAllowlist ?. length ) {
304+ if ( currentSettings . dmAllowlist !== undefined ) {
305305 effectiveDmAllowlist = currentSettings . dmAllowlist ;
306306 runtime . log ?.(
307307 `[tlon] Using dmAllowlist from settings store: ${ effectiveDmAllowlist . join ( ", " ) } ` ,
@@ -322,7 +322,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
322322 `[tlon] Using autoAcceptGroupInvites from settings store: ${ effectiveAutoAcceptGroupInvites } ` ,
323323 ) ;
324324 }
325- if ( currentSettings . groupInviteAllowlist ?. length ) {
325+ if ( currentSettings . groupInviteAllowlist !== undefined ) {
326326 effectiveGroupInviteAllowlist = currentSettings . groupInviteAllowlist ;
327327 runtime . log ?.(
328328 `[tlon] Using groupInviteAllowlist from settings store: ${ effectiveGroupInviteAllowlist . join ( ", " ) } ` ,
@@ -1176,17 +1176,14 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
11761176 return ;
11771177 }
11781178
1179- // Resolve any cited/quoted messages first
1180- const citedContent = await resolveAllCites ( content . content ) ;
11811179 const rawText = extractMessageText ( content . content ) ;
1182- const messageText = citedContent + rawText ;
1183- if ( ! messageText . trim ( ) ) {
1180+ if ( ! rawText . trim ( ) ) {
11841181 return ;
11851182 }
11861183
11871184 cacheMessage ( nest , {
11881185 author : senderShip ,
1189- content : messageText ,
1186+ content : rawText ,
11901187 timestamp : content . sent || Date . now ( ) ,
11911188 id : messageId ,
11921189 } ) ;
@@ -1200,7 +1197,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12001197 // Check if we should respond:
12011198 // 1. Direct mention always triggers response
12021199 // 2. Thread replies where we've participated - respond if relevant (let agent decide)
1203- const mentioned = isBotMentioned ( messageText , botShipName , botNickname ?? undefined ) ;
1200+ const mentioned = isBotMentioned ( rawText , botShipName , botNickname ?? undefined ) ;
12041201 const inParticipatedThread =
12051202 isThreadReply && parentId && participatedThreads . has ( String ( parentId ) ) ;
12061203
@@ -1227,10 +1224,10 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12271224 type : "channel" ,
12281225 requestingShip : senderShip ,
12291226 channelNest : nest ,
1230- messagePreview : messageText . substring ( 0 , 100 ) ,
1227+ messagePreview : rawText . substring ( 0 , 100 ) ,
12311228 originalMessage : {
12321229 messageId : messageId ?? "" ,
1233- messageText,
1230+ messageText : rawText ,
12341231 messageContent : content . content ,
12351232 timestamp : content . sent || Date . now ( ) ,
12361233 parentId : parentId ?? undefined ,
@@ -1248,6 +1245,10 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
12481245 }
12491246 }
12501247
1248+ // Resolve quoted content only after the sender passed channel authorization.
1249+ const citedContent = await resolveAllCites ( content . content ) ;
1250+ const messageText = citedContent + rawText ;
1251+
12511252 const parsed = parseChannelNest ( nest ) ;
12521253 await processMessage ( {
12531254 messageId : messageId ?? "" ,
@@ -1365,15 +1366,15 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
13651366 ) ;
13661367 }
13671368
1368- // Resolve any cited/quoted messages first
1369- const citedContent = await resolveAllCites ( essay . content ) ;
13701369 const rawText = extractMessageText ( essay . content ) ;
1371- const messageText = citedContent + rawText ;
1372- if ( ! messageText . trim ( ) ) {
1370+ if ( ! rawText . trim ( ) ) {
13731371 return ;
13741372 }
1373+ const citedContent = await resolveAllCites ( essay . content ) ;
1374+ const resolvedMessageText = citedContent + rawText ;
13751375
13761376 // Check if this is the owner sending an approval response
1377+ const messageText = rawText ;
13771378 if ( isOwner ( senderShip ) && isApprovalResponse ( messageText ) ) {
13781379 const handled = await handleApprovalResponse ( messageText ) ;
13791380 if ( handled ) {
@@ -1397,7 +1398,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
13971398 await processMessage ( {
13981399 messageId : messageId ?? "" ,
13991400 senderShip,
1400- messageText,
1401+ messageText : resolvedMessageText ,
14011402 messageContent : essay . content ,
14021403 isGroup : false ,
14031404 timestamp : essay . sent || Date . now ( ) ,
@@ -1430,7 +1431,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
14301431 await processMessage ( {
14311432 messageId : messageId ?? "" ,
14321433 senderShip,
1433- messageText,
1434+ messageText : resolvedMessageText ,
14341435 messageContent : essay . content , // Pass raw content for media extraction
14351436 isGroup : false ,
14361437 timestamp : essay . sent || Date . now ( ) ,
@@ -1524,8 +1525,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
15241525
15251526 // Update DM allowlist
15261527 if ( newSettings . dmAllowlist !== undefined ) {
1527- effectiveDmAllowlist =
1528- newSettings . dmAllowlist . length > 0 ? newSettings . dmAllowlist : account . dmAllowlist ;
1528+ effectiveDmAllowlist = newSettings . dmAllowlist ;
15291529 runtime . log ?.( `[tlon] Settings: dmAllowlist updated to ${ effectiveDmAllowlist . join ( ", " ) } ` ) ;
15301530 }
15311531
@@ -1551,10 +1551,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
15511551
15521552 // Update group invite allowlist
15531553 if ( newSettings . groupInviteAllowlist !== undefined ) {
1554- effectiveGroupInviteAllowlist =
1555- newSettings . groupInviteAllowlist . length > 0
1556- ? newSettings . groupInviteAllowlist
1557- : account . groupInviteAllowlist ;
1554+ effectiveGroupInviteAllowlist = newSettings . groupInviteAllowlist ;
15581555 runtime . log ?.(
15591556 `[tlon] Settings: groupInviteAllowlist updated to ${ effectiveGroupInviteAllowlist . join ( ", " ) } ` ,
15601557 ) ;
0 commit comments