@@ -19,14 +19,31 @@ function asString(value: unknown): string | null {
1919 return typeof value === 'string' && value . trim ( ) . length > 0 ? value . trim ( ) : null ;
2020}
2121
22- /** Build a mailing-list URL from doc_id or thread_id (e.g. Boost archives). */
22+ /**
23+ * Build a mailing-list URL (e.g. Boost archives).
24+ * Two cases:
25+ * 1. If metadata has list_name and doc_id (or msg_id) and the message id does not contain list_name,
26+ * URL is https://lists.boost.org/archives/list/{list_name}/message/{doc_id}/
27+ * 2. Otherwise use doc_id or thread_id as the list path: .../list/{doc_id_or_thread_id}/
28+ */
2329function generatorMailing ( metadata : Record < string , unknown > ) : UrlGenerationResult {
24- const docIdOrThread = asString ( metadata [ 'doc_id' ] ) ?? asString ( metadata [ 'thread_id' ] ) ;
30+ const listName = asString ( metadata [ 'list_name' ] ) ;
31+ const docId = asString ( metadata [ 'doc_id' ] ) ?? asString ( metadata [ 'msg_id' ] ) ;
32+ const threadId = asString ( metadata [ 'thread_id' ] ) ;
33+
34+ if ( listName && docId && ! docId . includes ( listName ) ) {
35+ return {
36+ url : `https://lists.boost.org/archives/list/${ listName } /message/${ docId } /` ,
37+ method : 'generated.mailing' ,
38+ } ;
39+ }
40+
41+ const docIdOrThread = docId ?? threadId ;
2542 if ( ! docIdOrThread ) {
2643 return {
2744 url : null ,
2845 method : 'unavailable' ,
29- reason : 'mailing requires doc_id or thread_id to generate URL' ,
46+ reason : 'mailing requires doc_id, msg_id, or thread_id to generate URL' ,
3047 } ;
3148 }
3249 return {
@@ -85,8 +102,3 @@ export function generateUrlForNamespace(
85102 reason : `URL generation is not supported for namespace "${ namespace } "` ,
86103 } ;
87104}
88-
89- /** Register a URL generator for a namespace (e.g. for custom indexes). */
90- export function registerUrlGenerator ( namespace : string , fn : UrlGenerator ) : void {
91- urlGenerators . set ( namespace , fn ) ;
92- }
0 commit comments