diff --git a/CHANGELOG.md b/CHANGELOG.md index 59d9d62..9e46d66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # develop + * BUG - Remove redundant `save_recording` method from `recording_menu` timeout and failure conditions to prevent voicemails from being saved multiple times. * BUG - Listening to new messages needs to set the `new_or_saved` metadata. Otherwise, after visiting saved messages, the status is always `:saved` * FEATURE - Refactor voicemail storage (backward incompatible change) * Pass storage instance in metadata to all controllers diff --git a/lib/voicemail/call_controllers/voicemail_controller.rb b/lib/voicemail/call_controllers/voicemail_controller.rb index c98e4b4..f211b24 100644 --- a/lib/voicemail/call_controllers/voicemail_controller.rb +++ b/lib/voicemail/call_controllers/voicemail_controller.rb @@ -1,7 +1,7 @@ module Voicemail class VoicemailController < ApplicationController - attr_accessor :recording + attr_accessor :recording, :recording_saved def run answer if config.when_to_answer == :before_greeting @@ -40,7 +40,7 @@ def play_recording_confirmation end def record_message - ensure_message_saved_if_hangup + ensure_message_saved_on_hangup @recording = record record_options @@ -53,22 +53,22 @@ def recording_menu match('2') { record_message } invalid { } - timeout { save_recording } - failure { save_recording } + timeout { } + failure { } end end private - def ensure_message_saved_if_hangup + def ensure_message_saved_on_hangup call.on_end do - save_recording if recording && !@saved + save_recording if recording && !recording_saved end end def save_recording storage.save_recording mailbox[:id], :new, call.from, recording.complete_event.recording - @saved = true + @recording_saved = true end def recording_url