@@ -904,16 +904,29 @@ def email_notification(version, build, email):
904
904
"""
905
905
log .debug (LOG_TEMPLATE .format (project = version .project .slug , version = version .slug ,
906
906
msg = 'sending email to: %s' % email ))
907
- context = {'version' : version ,
908
- 'project' : version .project ,
909
- 'build' : build ,
910
- 'build_url' : 'https://{0}{1}' .format (
911
- getattr (settings , 'PRODUCTION_DOMAIN' , 'readthedocs.org' ),
912
- build .get_absolute_url ()),
913
- 'unsub_url' : 'https://{0}{1}' .format (
914
- getattr (settings , 'PRODUCTION_DOMAIN' , 'readthedocs.org' ),
915
- reverse ('projects_notifications' , args = [version .project .slug ])),
916
- }
907
+
908
+ # We send only what we need from the Django model objects here to avoid
909
+ # serialization problems in the ``readthedocs.core.tasks.send_email_task``
910
+ context = {
911
+ 'version' : {
912
+ 'verbose_name' : version .verbose_name ,
913
+ },
914
+ 'project' : {
915
+ 'name' : version .project .name ,
916
+ },
917
+ 'build' : {
918
+ 'pk' : build .pk ,
919
+ 'error' : build .error ,
920
+ },
921
+ 'build_url' : 'https://{0}{1}' .format (
922
+ getattr (settings , 'PRODUCTION_DOMAIN' , 'readthedocs.org' ),
923
+ build .get_absolute_url (),
924
+ ),
925
+ 'unsub_url' : 'https://{0}{1}' .format (
926
+ getattr (settings , 'PRODUCTION_DOMAIN' , 'readthedocs.org' ),
927
+ reverse ('projects_notifications' , args = [version .project .slug ]),
928
+ ),
929
+ }
917
930
918
931
if build .commit :
919
932
title = _ ('Failed: {project.name} ({commit})' ).format (commit = build .commit [:8 ], ** context )
@@ -925,7 +938,7 @@ def email_notification(version, build, email):
925
938
title ,
926
939
template = 'projects/email/build_failed.txt' ,
927
940
template_html = 'projects/email/build_failed.html' ,
928
- context = context
941
+ context = context ,
929
942
)
930
943
931
944
@@ -951,7 +964,10 @@ def webhook_notification(version, build, hook_url):
951
964
log .debug (LOG_TEMPLATE
952
965
.format (project = project .slug , version = '' ,
953
966
msg = 'sending notification to: %s' % hook_url ))
954
- requests .post (hook_url , data = data )
967
+ try :
968
+ requests .post (hook_url , data = data )
969
+ except Exception :
970
+ log .exception ('Failed to POST on webhook url: url=%s' , hook_url )
955
971
956
972
957
973
@app .task (queue = 'web' )
0 commit comments