Merge branch 'master' into github-master

This commit is contained in:
斟酌 鵬兄 2016-02-20 03:31:13 +08:00
commit 8ed8ab07f4
5 changed files with 26 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ auth.js
db.js db.js
node_modules node_modules
*.swp *.swp
*.log

2
index.js Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/env node
require( "./botanss/package" ); require( "./botanss/package" );
require( "./config/global" ); require( "./config/global" );

1
logs/README Normal file
View File

@ -0,0 +1 @@
Allow access to www-data

View File

@ -12,6 +12,7 @@ class Notis
{ {
this.__valid = false; this.__valid = false;
this.__error = null; this.__error = null;
this.Retry = 0;
try try
{ {

View File

@ -115,6 +115,7 @@ class WNSAuth extends EventEmitter
Deliver( NotisQ ) Deliver( NotisQ )
{ {
var _self = this;
Model.Tokens Model.Tokens
.findOne({ name: NotisQ.id }) .findOne({ name: NotisQ.id })
.exec( ( err, data ) => { .exec( ( err, data ) => {
@ -128,6 +129,26 @@ class WNSAuth extends EventEmitter
{ {
this.__send( data.token, NotisQ, ( sender, e ) => { this.__send( data.token, NotisQ, ( sender, e ) => {
Dragonfly.Debug( "Send: " + e.statusCode ); Dragonfly.Debug( "Send: " + e.statusCode );
if( e.statusCode != 200 )
{
AuthToken = null;
Dragonfly.Info( "Perhaps access token is expired, retrying ..." );
if( NotisQ.Retry < 2 )
{
_self.once( "AuthComplete", () => {
NotisQ.Retry ++;
_self.Deliver( NotisQ );
});
}
else
{
Dragonfly.Info( "Retrying exceeded the limit, dropping the message" );
}
_self.Authenticate();
}
} ); } );
} }
else else