@@ -114,7 +114,12 @@ def send_notification(
114114 client = self .get_client ()
115115 try :
116116 client .chat_postMessage (
117- channel = target .resource_id , blocks = payload ["blocks" ], text = payload ["text" ]
117+ channel = target .resource_id ,
118+ blocks = payload ["blocks" ] if len (payload ["blocks" ]) > 0 else None ,
119+ text = payload ["text" ],
120+ attachments = payload .get ("attachments" ),
121+ unfurl_links = False ,
122+ unfurl_media = False ,
118123 )
119124 except SlackApiError as e :
120125 translate_slack_api_error (e )
@@ -132,8 +137,11 @@ def send_notification_with_threading(
132137 )
133138 kwargs : dict [str , Any ] = dict (
134139 channel = target .resource_id ,
135- blocks = payload ["blocks" ],
140+ blocks = payload ["blocks" ] if len ( payload [ "blocks" ]) > 0 else None ,
136141 text = payload ["text" ],
142+ attachments = payload .get ("attachments" ),
143+ unfurl_links = False ,
144+ unfurl_media = False ,
137145 )
138146
139147 if threading_context .thread_ts is not None :
@@ -159,8 +167,9 @@ def send_threaded_message(
159167 try :
160168 client .chat_postMessage (
161169 channel = channel_id ,
162- blocks = renderable ["blocks" ],
170+ blocks = renderable ["blocks" ] if len ( renderable [ "blocks" ]) > 0 else None ,
163171 text = renderable ["text" ],
172+ attachments = renderable .get ("attachments" ),
164173 thread_ts = thread_ts ,
165174 )
166175 except SlackApiError as e :
@@ -178,7 +187,8 @@ def send_threaded_ephemeral_message(
178187 try :
179188 client .chat_postEphemeral (
180189 channel = channel_id ,
181- blocks = renderable ["blocks" ],
190+ blocks = renderable ["blocks" ] if len (renderable ["blocks" ]) > 0 else None ,
191+ attachments = renderable .get ("attachments" ),
182192 text = renderable ["text" ],
183193 thread_ts = thread_ts ,
184194 user = slack_user_id ,
@@ -199,7 +209,10 @@ def update_message(
199209 channel = channel_id ,
200210 ts = message_ts ,
201211 text = renderable ["text" ],
202- blocks = renderable ["blocks" ],
212+ blocks = renderable ["blocks" ] if len (renderable ["blocks" ]) > 0 else None ,
213+ attachments = renderable .get ("attachments" ),
214+ unfurl_links = False ,
215+ unfurl_media = False ,
203216 )
204217 except SlackApiError as e :
205218 translate_slack_api_error (e )
0 commit comments