Skip to content

Commit

Permalink
updated disconnection logic, general cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan committed Aug 25, 2022
1 parent 1b6a5af commit a074496
Show file tree
Hide file tree
Showing 13 changed files with 11,364 additions and 436 deletions.
279 changes: 85 additions & 194 deletions app.js

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions models/accesslog.js

This file was deleted.

2 changes: 1 addition & 1 deletion models/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var NotificationSchema = new Schema({
icon: String,
severity: String,
acknowledged: Boolean,
created: { type: Date, default: Date.now }
created: { type: Date, default: Date.now, expires: '30d' }
});

NotificationSchema.index({user:1, created:1});
Expand Down
10 changes: 6 additions & 4 deletions models/openhab.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = mongoose.SchemaTypes.ObjectId,
OpenhabConfig = require('./openhabconfig')

ObjectId = mongoose.SchemaTypes.ObjectId;

var OpenhabSchema = new Schema({
name: String, // A meaningfull name of openHAB
uuid: {type: String, unique: true}, // openHAB generated UUID
Expand All @@ -16,7 +15,8 @@ var OpenhabSchema = new Schema({
last_online: { type: Date }, // last seen this openHAB online
last_email_notification: {type: Date}, // last notification about openHAB being offline for long time
status: {type: String, default: "offline"}, // current openHAB status (online/offline)
serverAddress: {type: String} // the host:port that this openhab is connected to
serverAddress: {type: String}, // the host:port that this openhab is connected to
connectionId: {type: String} // the local instance ID needed when marking openHABs offline
});

// Index for lookups by uuid
Expand All @@ -25,6 +25,8 @@ OpenhabSchema.index({uuid:1});
OpenhabSchema.index({account:1});
// Index for lookups by status
OpenhabSchema.index({status:1, last_online:1});
// Index for lookups by connectionId
OpenhabSchema.index({connectionId:1});

OpenhabSchema.methods.authenticate = function(openhabUuid, openhabSecret, callback) {
this.model('Openhab').findOne({uuid: openhabUuid, secret: openhabSecret}, function(error, openhab) {
Expand Down
16 changes: 0 additions & 16 deletions models/openhabaccesslog.js

This file was deleted.

13 changes: 0 additions & 13 deletions models/openhabconfig.js

This file was deleted.

Loading

0 comments on commit a074496

Please sign in to comment.