From 0f9a499a5727a7f19753165288f7aa27b604badd Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Mon, 26 Dec 2016 15:52:11 +0800
Subject: [PATCH] bugfix
---
method.js | 42 +++++++++++++++++++++++++-----------------
1 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/method.js b/method.js
index 7ba59d9..827b8f1 100644
--- a/method.js
+++ b/method.js
@@ -170,6 +170,7 @@
var _config = global.configs[mac];
if(_config == null) {
_config = {
+ mac: mac,
address: "���������������������������������",
location: {���
lat:31.430616,
@@ -181,6 +182,7 @@
open_id: "o-RTuwvMHWotyirPHLmdSB_dKoQU"
}
}
+ configs[mac] = _config;
}
var current = moment();
@@ -353,27 +355,33 @@
db.collection("devices").find().toArray(function(err, docs) {
docs.forEach(function(doc) {
var mac = doc.mac;
- var address = doc.address;
- var location = doc.location;
- var notice = doc.notice;
- if(notice == null) {
- var userID = doc.userID;
- db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){
+ if(mac != null) {
+ var address = doc.address || "";
+ var location = doc.location || {};
+ var notice = doc.notice;
+ if(notice == null || notice == {}) {
+ var userID = doc.userID;
+ db.collection("users").find({"_id": userID}).limit(1).next(function(err, user){
+ if(user) {
+ global.configs[mac] = {
+ mac: mac,
+ address: address,
+ location: location,
+ notice: {
+ tel: user.username,
+ email: user.email,
+ open_id: user.open_id
+ }
+ }
+ }
+ });
+ } else {
global.configs[mac] = {
+ mac: mac,
address: address,
location: location,
- notice: {
- tel: user.username,
- email: user.email,
- open_id: user.open_id
- }
+ notice: notice
}
- });
- } else {
- global.configs[mac] = {
- address: address,
- location: location,
- notice: notice
}
}
});
--
Gitblit v1.8.0