@@ -186,24 +186,23 @@ class Notificator {
186
186
}
187
187
}
188
188
189
- async parse_connect_file ( connect_filename_with_overrides , decrypt = false ) {
189
+ async parse_connect_file ( connection_name , decrypt = false ) {
190
190
let connect ;
191
- const filename_parts = connect_filename_with_overrides . split ( '?' ) ;
192
- const connect_filename_no_overrides = filename_parts [ 0 ] ;
193
- const overrides_str = filename_parts [ 1 ] ;
191
+ let connect_filename = connection_name ;
192
+ let kafka_topic_from_connection_name ;
193
+ if ( connection_name . startsWith ( "kafka:::topic/" ) ) {
194
+ const connection_parts = connection_name . split ( '/' ) ;
195
+ connect_filename = connection_parts [ 1 ] ;
196
+ kafka_topic_from_connection_name = connection_parts . length > 2 && connection_parts [ 3 ] ;
197
+ }
194
198
195
199
if ( this . nc_config_fs ) {
196
- connect = await this . nc_config_fs . get_connection_by_name ( connect_filename_no_overrides ) ;
200
+ connect = await this . nc_config_fs . get_connection_by_name ( connect_filename ) ;
197
201
} else {
198
- const filepath = path . join ( this . connect_files_dir , connect_filename_no_overrides ) ;
202
+ const filepath = path . join ( this . connect_files_dir , connect_filename ) ;
199
203
const connect_str = fs . readFileSync ( filepath , 'utf-8' ) ;
200
204
connect = JSON . parse ( connect_str ) ;
201
205
}
202
- if ( overrides_str ) {
203
- const overrides_obj = JSON . parse ( overrides_str ) ;
204
- _ . merge ( connect , overrides_obj ) ;
205
- dbg . log2 ( "effective connect =" , connect ) ;
206
- }
207
206
208
207
//if connect file is encrypted (and decryption is requested),
209
208
//decrypt the auth field
@@ -212,6 +211,11 @@ class Notificator {
212
211
connect . request_options_object . auth , connect . master_key_id ) ;
213
212
}
214
213
load_files ( connect ) ;
214
+
215
+ //use the kafka topic, if it was present in connection_name
216
+ if ( kafka_topic_from_connection_name ) {
217
+ connect . topic = kafka_topic_from_connection_name ;
218
+ }
215
219
return connect ;
216
220
}
217
221
}
@@ -371,6 +375,7 @@ async function test_notifications(notifs, nc_config_dir, req) {
371
375
let notif_failure ;
372
376
try {
373
377
connect = await notificator . parse_connect_file ( notif . topic [ 0 ] ) ;
378
+ dbg . log0 ( `effective connect for notif ${ notif . id [ 0 ] } is` , connect ) ;
374
379
connection = get_connection ( connect ) ;
375
380
await connection . connect ( ) ;
376
381
await connection . promise_notify ( compose_notification_test ( req ) , async ( notif_cb , err_cb , err ) => {
0 commit comments