@@ -511,18 +511,24 @@ def SlackNotify(msg, args):
511511 connections = get_connection (args )
512512 if not args .no_write :
513513 db = TinyDB ('previous_alerts.json' )
514+
514515 if 'notify' in connections :
515516 notify_config = connections ['notify' ]
516517 # Check if suppress_duplicates is set to True
517518 suppress_duplicates = notify_config .get ('suppress_duplicates' , False )
518-
519+ original_msg = msg
519520 if suppress_duplicates and not args .no_write :
520521 # Calculate the hash of the message
521- msg_hash = calculate_msg_hash (msg )
522+ ## check if "msg" has "Message Link" in any line, then remove that complete line
523+ if "Message Link" in msg :
524+ msg = msg .split ("\n " )
525+ msg = [line for line in msg if "Message Link" not in line ]
526+ msg = "\n " .join (msg )
522527
528+ msg_hash = calculate_msg_hash (msg )
523529 # Check if the message hash already exists in the previous alerts database
524- Alert = Query ()
525- if db .contains ( Alert . msg_hash == msg_hash ):
530+ alert_query = Query ()
531+ if db .search ( alert_query [ ' msg_hash' ] == msg_hash ):
526532 print_info (args , "Duplicate message detected. Skipping webhook trigger." )
527533 return
528534
@@ -531,11 +537,10 @@ def SlackNotify(msg, args):
531537 if webhook_url and webhook_url .startswith ('https://hooks.slack.com/services/' ):
532538 try :
533539 payload = {
534- 'text' : msg ,
540+ 'text' : original_msg ,
535541 }
536542 headers = {'Content-Type' : 'application/json' }
537543 requests .post (webhook_url , data = json .dumps (payload ), headers = headers )
538-
539544 if suppress_duplicates and not args .no_write :
540545 # Store the message hash in the previous alerts database
541546 db .insert ({'msg_hash' : msg_hash })
@@ -655,7 +660,29 @@ def get_jira_accId(args, email):
655660 return None
656661
657662def create_jira_ticket (args , issue_data , message ):
663+ orig_msg = message
658664 config = get_connection (args )
665+ if not args .no_write :
666+ db = TinyDB ('previous_alerts.json' )
667+ if 'notify' in config :
668+ notify_config = config ['notify' ]
669+ # Check if suppress_duplicates is set to True
670+ suppress_duplicates = notify_config .get ('suppress_duplicates' , False )
671+ if suppress_duplicates and not args .no_write :
672+ # Calculate the hash of the message
673+ ## check if "msg" has "Message Link" in any line, then remove that complete line
674+ if "Message Link" in message :
675+ message = message .split ("\n " )
676+ message = [line for line in message if "Message Link" not in line ]
677+ message = "\n " .join (message )
678+
679+ msg_hash = calculate_msg_hash (message )
680+ # Check if the message hash already exists in the previous alerts database
681+ alert_query = Query ()
682+ if db .search (alert_query ['msg_hash' ] == msg_hash ):
683+ print_info (args , "Duplicate message detected. Skipping ticket creation" )
684+ return
685+
659686 """Creates a Jira ticket using the provided configuration and issue data."""
660687 jira_config = config .get ('notify' , {}).get ('jira' , {})
661688
@@ -675,7 +702,7 @@ def create_jira_ticket(args, issue_data, message):
675702 summary = "Found " + str (total_matches ) + " " + issue_data .get ('pattern_name' ) + " in " + issue_data .get ('data_source' )
676703 summary = issue_fields .get ('summary_prefix' , '' ) + summary
677704 description_template = issue_fields .get ('description_template' , '' )
678- description = description_template .format (details = message , ** issue_data )
705+ description = description_template .format (details = orig_msg , ** issue_data )
679706
680707 payload = {
681708 "fields" : {
0 commit comments