@@ -35,6 +35,7 @@ import {
3535 isBotMentioned ,
3636 stripBotMention ,
3737 isDmAllowed ,
38+ isGroupInviteAllowed ,
3839 isSummarizationRequest ,
3940 resolveAuthorizedMessageText ,
4041 type ParsedCite ,
@@ -1084,69 +1085,22 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
10841085 // during transitions. The authorization check handles access control.
10851086 }
10861087
1087- // Update DM allowlist
1088- if ( newSettings . dmAllowlist !== undefined ) {
1089- effectiveDmAllowlist = newSettings . dmAllowlist ;
1090- runtime . log ?.( `[tlon] Settings: dmAllowlist updated to ${ effectiveDmAllowlist . join ( ", " ) } ` ) ;
1091- }
1092-
1093- // Update model signature setting
1094- if ( newSettings . showModelSig !== undefined ) {
1095- effectiveShowModelSig = newSettings . showModelSig ;
1096- runtime . log ?.( `[tlon] Settings: showModelSig = ${ effectiveShowModelSig } ` ) ;
1097- }
1098-
1099- // Update auto-accept DM invites setting
1100- if ( newSettings . autoAcceptDmInvites !== undefined ) {
1101- effectiveAutoAcceptDmInvites = newSettings . autoAcceptDmInvites ;
1102- runtime . log ?.( `[tlon] Settings: autoAcceptDmInvites = ${ effectiveAutoAcceptDmInvites } ` ) ;
1103- }
1104-
1105- // Update auto-accept group invites setting
1106- if ( newSettings . autoAcceptGroupInvites !== undefined ) {
1107- effectiveAutoAcceptGroupInvites = newSettings . autoAcceptGroupInvites ;
1108- runtime . log ?.(
1109- `[tlon] Settings: autoAcceptGroupInvites = ${ effectiveAutoAcceptGroupInvites } ` ,
1110- ) ;
1111- }
1112-
1113- // Update group invite allowlist
1114- if ( newSettings . groupInviteAllowlist !== undefined ) {
1115- effectiveGroupInviteAllowlist = newSettings . groupInviteAllowlist ;
1116- runtime . log ?.(
1117- `[tlon] Settings: groupInviteAllowlist updated to ${ effectiveGroupInviteAllowlist . join ( ", " ) } ` ,
1118- ) ;
1119- }
1120-
1121- if ( newSettings . defaultAuthorizedShips !== undefined ) {
1122- runtime . log ?.(
1123- `[tlon] Settings: defaultAuthorizedShips updated to ${ ( newSettings . defaultAuthorizedShips || [ ] ) . join ( ", " ) } ` ,
1124- ) ;
1125- }
1126-
1127- // Update auto-discover channels
1128- if ( newSettings . autoDiscoverChannels !== undefined ) {
1129- effectiveAutoDiscoverChannels = newSettings . autoDiscoverChannels ;
1130- runtime . log ?.( `[tlon] Settings: autoDiscoverChannels = ${ effectiveAutoDiscoverChannels } ` ) ;
1131- }
1132-
1133- // Update owner ship
1134- if ( newSettings . ownerShip !== undefined ) {
1135- effectiveOwnerShip = newSettings . ownerShip
1136- ? normalizeShip ( newSettings . ownerShip )
1137- : account . ownerShip
1138- ? normalizeShip ( account . ownerShip )
1139- : null ;
1140- runtime . log ?.( `[tlon] Settings: ownerShip = ${ effectiveOwnerShip } ` ) ;
1141- }
1142-
1143- // Update pending approvals
1144- if ( newSettings . pendingApprovals !== undefined ) {
1145- pendingApprovals = newSettings . pendingApprovals ;
1146- runtime . log ?.(
1147- `[tlon] Settings: pendingApprovals updated (${ pendingApprovals . length } items)` ,
1148- ) ;
1149- }
1088+ // Recompute effective settings from the latest snapshot so deletions
1089+ // cleanly fall back to file config and empty arrays remain authoritative.
1090+ ( {
1091+ effectiveDmAllowlist,
1092+ effectiveShowModelSig,
1093+ effectiveAutoAcceptDmInvites,
1094+ effectiveAutoAcceptGroupInvites,
1095+ effectiveGroupInviteAllowlist,
1096+ effectiveAutoDiscoverChannels,
1097+ effectiveOwnerShip,
1098+ pendingApprovals,
1099+ } = applyTlonSettingsOverrides ( {
1100+ account,
1101+ currentSettings : newSettings ,
1102+ log : ( message ) => runtime . log ?.( message ) ,
1103+ } ) ) ;
11501104 } ) ;
11511105
11521106 try {
@@ -1300,8 +1254,6 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
13001254 }
13011255
13021256 const inviterShip = validInvite . from ;
1303- const normalizedInviter = normalizeShip ( inviterShip ) ;
1304-
13051257 // Owner invites are always accepted
13061258 if ( isOwner ( inviterShip ) ) {
13071259 try {
@@ -1337,12 +1289,7 @@ export async function monitorTlonProvider(opts: MonitorTlonOpts = {}): Promise<v
13371289 }
13381290
13391291 // Check if inviter is on allowlist
1340- const isAllowed =
1341- effectiveGroupInviteAllowlist . length > 0
1342- ? effectiveGroupInviteAllowlist
1343- . map ( ( s ) => normalizeShip ( s ) )
1344- . some ( ( s ) => s === normalizedInviter )
1345- : false ; // Fail-safe: empty allowlist means deny
1292+ const isAllowed = isGroupInviteAllowed ( inviterShip , effectiveGroupInviteAllowlist ) ;
13461293
13471294 if ( ! isAllowed ) {
13481295 // If owner is configured, queue approval
0 commit comments