Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voicemail messages shouldn't save on timeout. #48

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions lib/voicemail/call_controllers/voicemail_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down