Minor bug fixes
This commit is contained in:
parent
0f2ca2e162
commit
bc77a9d371
@ -67,6 +67,13 @@ class WNSAuth extends EventEmitter
|
|||||||
var uuid = Rand.uuid();
|
var uuid = Rand.uuid();
|
||||||
|
|
||||||
_self.__send( ChannelUri, N, ( sender, e ) => {
|
_self.__send( ChannelUri, N, ( sender, e ) => {
|
||||||
|
|
||||||
|
if( typeof( e ) == "string" )
|
||||||
|
{
|
||||||
|
handler( _self, e );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( e.statusCode == 200 )
|
if( e.statusCode == 200 )
|
||||||
{
|
{
|
||||||
Model.Tokens.update(
|
Model.Tokens.update(
|
||||||
@ -83,11 +90,8 @@ class WNSAuth extends EventEmitter
|
|||||||
}
|
}
|
||||||
handler( _self, uuid );
|
handler( _self, uuid );
|
||||||
} );
|
} );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handler( _self, e.statusCode + " Server Error: Unable to push message to channel" );
|
handler( _self, e.statusCode + " Server Error: Unable to push message to channel" );
|
||||||
|
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -134,24 +138,32 @@ class WNSAuth extends EventEmitter
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Request = new HttpRequest( ChannelUri, {
|
try
|
||||||
"Authorization": "Bearer " + AuthToken
|
|
||||||
, "X-WNS-RequestForStatus": "true"
|
|
||||||
, "X-WNS-Type": "wns/toast"
|
|
||||||
} );
|
|
||||||
|
|
||||||
if( !Request.Hostname.match( /.*\.notify\.windows\.com$/ ) )
|
|
||||||
{
|
{
|
||||||
handler( this, "Malicious hostname: " + Request.Hostname );
|
var Request = new HttpRequest( ChannelUri, {
|
||||||
|
"Authorization": "Bearer " + AuthToken
|
||||||
|
, "X-WNS-RequestForStatus": "true"
|
||||||
|
, "X-WNS-Type": "wns/toast"
|
||||||
|
} );
|
||||||
|
|
||||||
|
if( !Request.Hostname.match( /.*\.notify\.windows\.com$/ ) )
|
||||||
|
{
|
||||||
|
handler( this, "Malicious hostname: " + Request.Hostname );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Request.PostData( NotisQ.Xml );
|
||||||
|
Request.Headers[ "Content-Type" ] = "text/xml";
|
||||||
|
|
||||||
|
Request.addListener( "RequestComplete", handler );
|
||||||
|
|
||||||
|
Request.Send();
|
||||||
|
}
|
||||||
|
catch( ex )
|
||||||
|
{
|
||||||
|
handler( this, ex.message );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Request.PostData( NotisQ.Xml );
|
|
||||||
Request.Headers[ "Content-Type" ] = "text/xml";
|
|
||||||
|
|
||||||
Request.addListener( "RequestComplete", handler );
|
|
||||||
|
|
||||||
Request.Send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__authWNS()
|
__authWNS()
|
||||||
|
@ -80,12 +80,13 @@ class App extends Base
|
|||||||
|
|
||||||
ProcessQueue()
|
ProcessQueue()
|
||||||
{
|
{
|
||||||
if( !this.RequestQueue.length ) return;
|
if(!( this.RequestQueue && this.RequestQueue.length ))
|
||||||
|
{
|
||||||
|
this.RequestQueue = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var Request = this.RequestQueue.shift();
|
var Request = this.RequestQueue.shift();
|
||||||
|
|
||||||
Dragonfly.Info( "Processing Request: " + Request );
|
|
||||||
|
|
||||||
this.OAuth.Deliver( Request );
|
this.OAuth.Deliver( Request );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@ var R_Tokens = { type: Schema.Types.ObjectId, ref: "Tokens" };
|
|||||||
var M_Tokens = new Schema({
|
var M_Tokens = new Schema({
|
||||||
name: { type: String, unique: true }
|
name: { type: String, unique: true }
|
||||||
, token: { type: String }
|
, token: { type: String }
|
||||||
|
, date_created: {
|
||||||
|
type: Date
|
||||||
|
, default: Date.now
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user