def write_syndicate_user_id( pubkey_pem, user_id, volume ): uid_path = storage.volume_path( USER_STORAGE_DIR, "syndicate_user_id" ) return storage.write_encrypted_file( pubkey_pem, uid_path, user_id, volume=volume )
return contact # ------------------------------------- def write_contact( pubkey_str, contact ): global STORAGE_DIR contact_path = make_contact_path( pubkey_str, contact.addr ) try: contact_json = storage.tuple_to_json( contact ) except Exception, e: log.error("Failed to serialize contact") log.exception(e) return False rc = storage.write_encrypted_file( pubkey_str, contact_path, contact_json ) if not rc: return False # purge contacts cache storage.purge_cache( CACHED_CONTACT_LIST ) return True # ------------------------------------- def contact_exists( pubkey_str, email_addr ): contact_path = make_contact_path( pubkey_str, email_addr ) return storage.path_exists( contact_path ) # ------------------------------------- def add_contact( pubkey_str, email_addr, contact_pubkey_str, contact_fields ):
#------------------------- def store_message( receiver_pubkey_str, sender_privkey_str, folder, message, attachment_paths, attachment_data ): try: message_json = storage.tuple_to_json( message ) except Exception, e: log.error("Failed to serialize message") log.exception(e) return False # what files have been stored? stored = [] # store message mpath = stored_message_path( receiver_pubkey_str, folder, message.timestamp, message.id ) rc = storage.write_encrypted_file( receiver_pubkey_str, mpath, message_json, sender_privkey_pem=sender_privkey_str ) if not rc: log.error("Failed to store message") return False stored.append( mpath ) failed = False """ # FIXME: broken--send one attachment per sender, or one per receiver. for attachment_name in message.attachment_names: attachment_path = attachment_paths[attachment_name] attachment_data = attachment_data[attachment_name] rc = storage.write_encrypted_file( receiver_pubkey_str, attachment_path, attachment_data ) if not rc: failed = True