def delete_greeting(self, voicemail_id, greeting): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) self._ari.wazo.removeVoicemailGreeting( context=vm_conf['context'], voicemail=vm_conf['number'], greeting=greeting, )
def get_message_recording(self, voicemail_id, message_id): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) message_info, recording = self._storage.get_message_info_and_recording( vm_conf, message_id) if message_info['folder'].is_unread: dest_folder = self._storage.get_folder_by_type( VoicemailFolderType.old) self._move_message(vm_conf, message_info, dest_folder) return recording
def delete_message(self, voicemail_id, message_id): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) message_info = self._storage.get_message_info(vm_conf, message_id) body = { 'mailbox': vm_conf['number'], 'context': vm_conf['context'], 'folder': message_info['folder'].path.decode('utf-8'), 'message_id': message_id, } self._ari.wazo.deleteVoicemailMessage(body=body)
def get_greeting(self, voicemail_id, greeting): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) try: return base64.b64decode( self._ari.wazo.getVoicemailGreeting( context=vm_conf['context'], voicemail=vm_conf['number'], greeting=greeting, )['greeting_base64'].encode()) except ARIHTTPError as e: if e.original_error.response.status_code == 404: raise NoSuchVoicemailGreeting(greeting) raise
def create_greeting(self, voicemail_id, greeting, data): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) body = {'greeting_base64': base64.b64encode(data).decode()} try: self._ari.wazo.createVoicemailGreeting(context=vm_conf['context'], voicemail=vm_conf['number'], greeting=greeting, body=body) except requests.HTTPError as e: # FIXME(sileht): Why ari-py does not raise ARIHTTPError for 400 ? if e.response.status_code == 400: raise InvalidVoicemailGreeting(greeting) except ARIHTTPError as e: if e.original_error.response.status_code == 409: raise VoicemailGreetingAlreadyExists(greeting) raise
def move_message(self, voicemail_id, message_id, dest_folder_id): dest_folder = self._storage.get_folder_by_id(dest_folder_id) vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) message_info = self._storage.get_message_info(vm_conf, message_id) self._move_message(vm_conf, message_info, dest_folder)
def get_message(self, voicemail_id, message_id): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) return self._storage.get_message_info(vm_conf, message_id)
def get_folder(self, voicemail_id, folder_id): vm_conf = confd.get_voicemail(voicemail_id, self._confd_client) return self._storage.get_folder_info(vm_conf, folder_id)