@@ -253,19 +253,19 @@ def enhancement_is_ready(video: Video) -> bool:
253253 return AIEnhancement .objects .filter (video = video , is_ready = True ).exists ()
254254
255255
256- def notify_user (video : Video ):
256+ def notify_user (video : Video , success : bool = True ):
257257 """Notify user at the end of enhancement."""
258258 if (
259259 USE_NOTIFICATIONS
260260 and video .owner .owner .accepts_notifications
261261 and PushInformation .objects .filter (user = video .owner ).exists ()
262262 ):
263- send_notification_enhancement (video )
263+ send_notification_enhancement (video , success )
264264 if EMAIL_ON_ENHANCEMENT_COMPLETION :
265- send_email_enhancement (video )
265+ send_email_enhancement (video , success )
266266
267267
268- def send_notification_enhancement (video ):
268+ def send_notification_enhancement (video , success : bool = True ):
269269 """Send push notification on video encoding or transcripting completion."""
270270 subject = "[%s] %s" % (
271271 __TITLE_SITE__ ,
@@ -279,6 +279,14 @@ def send_notification_enhancement(video):
279279 "content_title" : video .title ,
280280 "site_title" : __TITLE_SITE__ ,
281281 }
282+ if not success :
283+ message = _ (
284+ "Something went wrong with AI improvement on “%(content_title)s”."
285+ + " Suggestions for improvement can’t be available on %(site_title)s."
286+ ) % {
287+ "content_title" : video .title ,
288+ "site_title" : __TITLE_SITE__ ,
289+ }
282290
283291 pwa_notify_user (
284292 video .owner ,
@@ -288,30 +296,38 @@ def send_notification_enhancement(video):
288296 )
289297
290298
291- def send_email_enhancement (video ) -> None :
299+ def send_email_enhancement (video , success : bool = True ) -> None :
292300 """Send email notification on video improvement completion."""
293301 if DEBUG :
294- logger .info ("SEND EMAIL ON IA IMPROVEMENT COMPLETION" )
302+ logger .info ("SEND EMAIL ON AI IMPROVEMENT COMPLETION %s" , success )
295303 url_scheme = "https" if SECURE_SSL_REDIRECT else "http"
296304 content_url = "%s:%s" % (url_scheme , video .get_full_url ())
297305 subject = "[%s] %s" % (
298306 __TITLE_SITE__ ,
299- _ ("IA improvement #%(content_id)s completed" ) % {"content_id" : video .id },
307+ _ ("AI improvement #%(content_id)s completed" ) % {"content_id" : video .id },
300308 )
309+ main_text = _ (
310+ "AI improvement “%(content_title)s” has been completed"
311+ + ", and is now available on %(site_title)s."
312+ ) % {
313+ "content_title" : "<strong>%s</strong>" % video .title ,
314+ "site_title" : __TITLE_SITE__ ,
315+ }
316+ if not success :
317+ main_text = _ (
318+ "Something went wrong with AI improvement on “%(content_title)s” "
319+ + " on %(site_title)s."
320+ ) % {
321+ "content_title" : "<strong>%s</strong>" % video .title ,
322+ "site_title" : __TITLE_SITE__ ,
323+ }
301324
302325 html_message = (
303326 '<p>%s</p><p>%s</p><p>%s<br><a href="%s"><i>%s</i></a>\
304327 </p><p>%s</p>'
305328 % (
306329 _ ("Hello," ),
307- _ (
308- "IA improvement “%(content_title)s” has been completed"
309- + ", and is now available on %(site_title)s."
310- )
311- % {
312- "content_title" : "<strong>%s</strong>" % video .title ,
313- "site_title" : __TITLE_SITE__ ,
314- },
330+ main_text ,
315331 _ ("You will find it here:" ),
316332 content_url ,
317333 content_url ,
0 commit comments