File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed
Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,11 @@ def audio(campaign_id):
263263 twilio_client = current_app .config .get ('TWILIO_CLIENT' )
264264 twilio_capability = ClientCapabilityToken (* twilio_client .auth )
265265 twilio_capability .allow_client_outgoing (current_app .config .get ('TWILIO_PLAYBACK_APP' ))
266+ twilio_jwt = twilio_capability .to_jwt ()
267+ if type (twilio_jwt ) == bytes :
268+ twilio_jwt_str = twilio_capability .to_jwt ().decode ('UTF-8' )
269+ elif type (twilio_jwt ) == str :
270+ twilio_jwt_str = twilio_jwt
266271
267272 for field in form :
268273 campaign_audio , is_default_message = campaign .audio_or_default (field .name )
@@ -279,7 +284,7 @@ def audio(campaign_id):
279284 return redirect (url_for ('campaign.launch' , campaign_id = campaign .id ))
280285
281286 return render_template ('campaign/audio.html' , campaign = campaign , form = form ,
282- twilio_capability = twilio_capability . to_jwt (). decode ( 'UTF-8' ) ,
287+ twilio_jwt = twilio_jwt_str ,
283288 descriptions = current_app .config .CAMPAIGN_FIELD_DESCRIPTIONS ,
284289 example_text = current_app .config .CAMPAIGN_MESSAGE_DEFAULTS )
285290
Original file line number Diff line number Diff line change @@ -69,8 +69,8 @@ $(document).ready(function () {
6969 navigator . msGetUserMedia ) ;
7070 window . URL = window . URL || window . webkitURL ;
7171
72- if ( CallPower . Config . TWILIO_CAPABILITY ) {
73- this . setupTwilioClient ( CallPower . Config . TWILIO_CAPABILITY ) ;
72+ if ( CallPower . Config . TWILIO_JWT ) {
73+ this . setupTwilioClient ( CallPower . Config . TWILIO_JWT ) ;
7474 }
7575
7676 // add required fields client-side
@@ -185,10 +185,10 @@ $(document).ready(function () {
185185 button . children ( '.text' ) . html ( 'Play' ) ;
186186 } ,
187187
188- setupTwilioClient : function ( capability ) {
188+ setupTwilioClient : function ( token ) {
189189 //connect twilio API to read text-to-speech
190190 try {
191- this . twilio = Twilio . Device . setup ( capability , { "debug" :CallPower . Config . DEBUG | false } ) ;
191+ this . twilio = Twilio . Device . setup ( token , { "debug" :CallPower . Config . DEBUG | false } ) ;
192192 } catch ( e ) {
193193 console . error ( e ) ;
194194 msg = 'Sorry, your browser does not support WebRTC, Text-to-Speech playback may not work.<br/>' +
Original file line number Diff line number Diff line change 2323 navigator . msGetUserMedia ) ;
2424 window . URL = window . URL || window . webkitURL ;
2525
26- if ( CallPower . Config . TWILIO_CAPABILITY ) {
27- this . setupTwilioClient ( CallPower . Config . TWILIO_CAPABILITY ) ;
26+ if ( CallPower . Config . TWILIO_JWT ) {
27+ this . setupTwilioClient ( CallPower . Config . TWILIO_JWT ) ;
2828 }
2929
3030 // add required fields client-side
139139 button . children ( '.text' ) . html ( 'Play' ) ;
140140 } ,
141141
142- setupTwilioClient : function ( capability ) {
142+ setupTwilioClient : function ( token ) {
143143 //connect twilio API to read text-to-speech
144144 try {
145- this . twilio = Twilio . Device . setup ( capability , { "debug" :CallPower . Config . DEBUG | false } ) ;
145+ this . twilio = Twilio . Device . setup ( token , { "debug" :CallPower . Config . DEBUG | false } ) ;
146146 } catch ( e ) {
147147 console . error ( e ) ;
148148 msg = 'Sorry, your browser does not support WebRTC, Text-to-Speech playback may not work.<br/>' +
Original file line number Diff line number Diff line change 5353< script >
5454 window . CallPower = {
5555 Config : {
56- { % if twilio_capability % } TWILIO_CAPABILITY : "{{twilio_capability }}" , { % endif% }
56+ { % if twilio_jwt % } TWILIO_JWT : "{{twilio_jwt }}" , { % endif% }
5757 }
5858 } ;
5959</ script >
You can’t perform that action at this time.
0 commit comments