def save_draft(crispin_client, account_id, message_id, args):
 with session_scope(account_id) as db_session:
  message = db_session.query(Message).get(message_id)
  version = args.get('version')
  if (message is None):
   log.info('tried to save nonexistent message as draft', message_id=message_id, account_id=account_id)
   return
  if (not message.is_draft):
   log.warning('tried to save non-draft message as draft', message_id=message_id, account_id=account_id)
   return
  if (version != message.version):
   log.warning('tried to save outdated version of draft')
   return
 remote_save_draft(crispin_client, account_id, message_id)

def save_draft ( crispin_client , account_id , message_id , args ) : with session_scope ( account_id ) as db_session : message = db_session . query ( Message ) . get ( message_id ) version = args . get ( 'version' ) if ( message is None ) : log . info ( 'tried to save nonexistent message as draft' , message_id = message_id , account_id = account_id ) return if ( not message . is_draft ) : log . warning ( 'tried to save non-draft message as draft' , message_id = message_id , account_id = account_id ) return if ( version != message . version ) : log . warning ( 'tried to save outdated version of draft' ) return remote_save_draft ( crispin_client , account_id , message_id )
sync a new draft back to the remote backend .