#NEWLINE# def create_missed_message_address( user_profile , message ) : #NEWLINE# #INDENT# if ( message . recipient . type == Recipient . PERSONAL ) : #NEWLINE# #INDENT# recipient_id = get_recipient ( Recipient . PERSONAL , message . sender_id ) . id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# recipient_id = message . recipient_id #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'user_profile_id' : user_profile . id , #NEWLINE# 'recipient_id' : recipient_id , #NEWLINE# 'subject' : message . subject , #NEWLINE# #UNINDENT# } #NEWLINE# while True : #NEWLINE# #INDENT# token = generate_random_token ( 32 ) #NEWLINE# key = missed_message_redis_key ( token ) #NEWLINE# if redis_client . hsetnx ( key , 'uses_left' , 1 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# with redis_client . pipeline ( ) as pipeline : #NEWLINE# #INDENT# pipeline . hmset ( key , key ) #NEWLINE# pipeline . expire ( key , ( ( ( 60 * 60 ) * 24 ) * 5 ) ) #NEWLINE# pipeline . execute ( ) #NEWLINE# #UNINDENT# address = ( 'mm' + token ) #NEWLINE# return ( settings . EMAIL_GATEWAY_PATTERN % ( address , ) )