From b46ab80284a50575dd7078b9958ce3be21acc594 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 17 May 2013 09:34:20 +0200 Subject: voicemail_message method in call_history --- app/models/call_history.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'app/models') diff --git a/app/models/call_history.rb b/app/models/call_history.rb index 81342bd..8ccf4e3 100644 --- a/app/models/call_history.rb +++ b/app/models/call_history.rb @@ -133,19 +133,14 @@ class CallHistory < ActiveRecord::Base end - def voicemail_message? - begin - return self.call_historyable.voicemail_messages.where(:forwarded_by => self.caller_channel_uuid).any? - rescue - return nil - end - end - def voicemail_message - begin - return self.call_historyable.voicemail_messages.where(:forwarded_by => self.caller_channel_uuid).first - rescue - return nil + if self.callee_account_type.downcase == 'voicemailaccount' + voicemail_account = VoicemailAccount.where(:id => self.callee_account_id).first + if voicemail_account + return voicemail_account.voicemail_messages.where(:forwarded_by => self.caller_channel_uuid).first + else + return nil + end end end -- cgit v1.2.3