Class: Voicemail::VoicemailController

Inherits:
ApplicationController show all
Defined in:
lib/voicemail/voicemail_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#main_menu

Instance Method Details

#handle_recordingObject



17
18
19
20
21
# File 'lib/voicemail/voicemail_controller.rb', line 17

def handle_recording
  @from = call.from
  record_comp = record config.recording.to_hash.merge(interruptible: true, max_duration: 30_000, direction: :recv)
  save_recording record_comp.complete_event.recording.uri
end

#mailbox_not_foundObject



23
24
25
26
# File 'lib/voicemail/voicemail_controller.rb', line 23

def mailbox_not_found
  play config.mailbox_not_found
  hangup
end

#play_greetingObject



13
14
15
# File 'lib/voicemail/voicemail_controller.rb', line 13

def play_greeting
  play mailbox[:greeting_message] || config.default_greeting
end

#runObject



3
4
5
6
7
8
9
10
11
# File 'lib/voicemail/voicemail_controller.rb', line 3

def run
  answer
  if mailbox
    play_greeting
    handle_recording
  else
    mailbox_not_found
  end
end

#save_recording(uri) ⇒ Object



28
29
30
# File 'lib/voicemail/voicemail_controller.rb', line 28

def save_recording(uri)
  storage.save_recording mailbox[:id], @from, uri
end