def post(self, *args, **kwargs): call = Call.objects.get(twilio_sid=self.request.POST['CallSid']) calls_connected = Call.objects.filter(conference=call.conference, call_state=Call.IN_CALL) call_event = CallEvent(call=call, event_type=CallEvent.JOIN) call_event.save() r = twiml.Response() r.say('We are now connecting you') if calls_connected.exists(): twilio_client = TwilioRestClient(settings.TWILIO_SID, settings.TWILIO_TOKEN) r.pause(length=1) r.say('The following people are already on the call') for c in calls_connected: name = "{} {}".format(c.user.first_name, c.user.last_name) r.say(name) r.pause(length=1) url = reverse('conference_announce', args=(call.conference.id, call.user.id,)) twilio_client.calls.update(c.twilio_sid, method="POST", url=settings.BASE_URL+url) with r.dial() as d: d.conference(name=str(call.conference.twilio_name), eventCallbackUrl=settings.BASE_URL + reverse('voice_conference_status'), record="record-from-start") call.call_state = Call.IN_CALL call.save() return HttpResponse(r.toxml())
def initiate_conference_call(self, conference, user): path = reverse('conference_response', args=(conference.id, )) url = "{}{}".format(settings.BASE_URL, path) sid = self._make_call(user.userprofile.phone_number, self.calling_number, url) call = Call(conference=conference, user=user, twilio_sid=sid) call.save() call_event = CallEvent(call=call, event_type=CallEvent.CALL) call_event.save()
def post(self, *args, **kwargs): DONE_STATUS = ['canceled', 'completed', 'failed', 'busy', 'no-answer'] call = Call.objects.get(twilio_sid=self.request.POST['CallSid']) status = self.request.POST['CallStatus'] if status in DONE_STATUS: call.call_state = Call.DONE call.save() call_event = CallEvent(call=call, event_type=CallEvent.LEAVE) call_event.save() return HttpResponse("")
def initiate_conference_call(self, conference, user): path = reverse('conference_response', args=(conference.id,)) url = "{}{}".format( settings.BASE_URL, path) sid = self._make_call(user.userprofile.phone_number, self.calling_number, url) call = Call(conference=conference, user=user, twilio_sid=sid) call.save() call_event = CallEvent(call=call, event_type=CallEvent.CALL) call_event.save()
def post(self, *args, **kwargs): call = Call.objects.get(twilio_sid=self.request.POST['CallSid']) calls_connected = Call.objects.filter(conference=call.conference, call_state=Call.IN_CALL) call_event = CallEvent(call=call, event_type=CallEvent.JOIN) call_event.save() r = twiml.Response() r.say('We are now connecting you') if calls_connected.exists(): twilio_client = TwilioRestClient(settings.TWILIO_SID, settings.TWILIO_TOKEN) r.pause(length=1) r.say('The following people are already on the call') for c in calls_connected: name = "{} {}".format(c.user.first_name, c.user.last_name) r.say(name) r.pause(length=1) url = reverse('conference_announce', args=( call.conference.id, call.user.id, )) twilio_client.calls.update(c.twilio_sid, method="POST", url=settings.BASE_URL + url) with r.dial() as d: d.conference(name=str(call.conference.twilio_name), eventCallbackUrl=settings.BASE_URL + reverse('voice_conference_status'), record="record-from-start") call.call_state = Call.IN_CALL call.save() return HttpResponse(r.toxml())