@@ -17,12 +17,20 @@ const INBOUND_MESSAGE_TS_KEYS = new Set([
1717] ) ;
1818
1919export function findInboundMessageTimestamp ( value : unknown , depth = 0 , seen = new Set < object > ( ) ) : string {
20- if ( depth > 5 || value === null || value === undefined ) return "" ;
20+ if ( value === null || value === undefined ) return "" ;
2121 if ( typeof value === "string" ) {
2222 const text = value . trim ( ) ;
2323 return SLACK_MESSAGE_TS_PATTERN . test ( text ) ? text : "" ;
2424 }
25- if ( typeof value !== "object" || Array . isArray ( value ) ) return "" ;
25+ if ( depth > 5 ) return "" ;
26+ if ( Array . isArray ( value ) ) {
27+ for ( const item of value ) {
28+ const nested = findInboundMessageTimestamp ( item , depth + 1 , seen ) ;
29+ if ( nested ) return nested ;
30+ }
31+ return "" ;
32+ }
33+ if ( typeof value !== "object" ) return "" ;
2634 if ( seen . has ( value ) ) return "" ;
2735 seen . add ( value ) ;
2836 const record = value as UnknownRecord ;
@@ -132,7 +140,7 @@ export function resolveSlackMessageReceivedSessionKey(event: UnknownRecord, ctx:
132140/** Scan ALL string values in an object tree for a Slack ts pattern.
133141 * Used as a fallback when the key name is non-standard. */
134142function findAnySlackTs ( value : unknown , depth = 0 , seen = new Set < object > ( ) ) : string {
135- if ( depth > 4 || value === null || value === undefined ) return "" ;
143+ if ( value === null || value === undefined ) return "" ;
136144 if ( typeof value === "string" ) {
137145 // Only match strings that look like a standalone Slack ts (not embedded in a larger number)
138146 if ( SLACK_MESSAGE_TS_PATTERN . test ( value . trim ( ) ) ) return value . trim ( ) ;
@@ -141,7 +149,15 @@ function findAnySlackTs(value: unknown, depth = 0, seen = new Set<object>()): st
141149 if ( m ) return m [ 1 ] ;
142150 return "" ;
143151 }
144- if ( typeof value !== "object" || Array . isArray ( value ) ) return "" ;
152+ if ( depth > 4 ) return "" ;
153+ if ( Array . isArray ( value ) ) {
154+ for ( const item of value ) {
155+ const found = findAnySlackTs ( item , depth + 1 , seen ) ;
156+ if ( found ) return found ;
157+ }
158+ return "" ;
159+ }
160+ if ( typeof value !== "object" ) return "" ;
145161 if ( seen . has ( value as object ) ) return "" ;
146162 seen . add ( value as object ) ;
147163 for ( const v of Object . values ( value as Record < string , unknown > ) ) {
0 commit comments