99from framework .auth .views import mails
1010from osf .models import Preprint
1111from website import settings
12+ from website .preprints .tasks import mint_doi_on_crossref_fail
1213
1314logger = logging .getLogger (__name__ )
1415
@@ -66,8 +67,7 @@ def post(self, request):
6667 elif record .get ('status' ).lower () == 'failure' :
6768 if 'Relation target DOI does not exist' in record .find ('msg' ).text :
6869 logger .warning ('Related publication DOI does not exist, sending metadata again without it...' )
69- client = preprint .get_doi_client ()
70- client .create_identifier (preprint , category = 'doi' , include_relation = False )
70+ mint_doi_on_crossref_fail .apply_async (kwargs = {'preprint_id' : preprint ._id })
7171 # This error occurs when a single preprint is being updated several times in a row with the same metadata [#PLAT-944]
7272 elif 'less or equal to previously submitted version' in record .find ('msg' ).text and record_count == 2 :
7373 break
@@ -78,12 +78,13 @@ def post(self, request):
7878 if dois_processed != record_count or status != 'completed' :
7979 if unexpected_errors :
8080 batch_id = crossref_email_content .find ('batch_id' ).text
81+ email_error_text = request .POST ['body-plain' ]
8182 mails .send_mail (
8283 to_addr = settings .OSF_SUPPORT_EMAIL ,
8384 mail = mails .CROSSREF_ERROR ,
8485 batch_id = batch_id ,
85- email_content = request . POST [ 'body-plain' ] ,
86+ email_content = email_error_text ,
8687 )
87- logger .error (f'Error submitting metadata for batch_id { batch_id } with CrossRef, email sent to help desk' )
88+ logger .error (f'Error submitting metadata for batch_id { batch_id } with CrossRef, email sent to help desk: { email_error_text } ' )
8889
8990 return HttpResponse ('Mail received' , status = 200 )
0 commit comments