mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-22 09:12:19 -05:00
Add timezone and disco fetching to resource model
This commit is contained in:
parent
53950d9320
commit
ae364437ec
@ -1,3 +1,4 @@
|
||||
/*global app, client*/
|
||||
"use strict";
|
||||
|
||||
var HumanModel = require('human-model');
|
||||
@ -8,11 +9,35 @@ module.exports = HumanModel.define({
|
||||
type: 'resource',
|
||||
session: {
|
||||
id: ['string', true],
|
||||
jid: ['string', true],
|
||||
status: ['string', true, ''],
|
||||
show: ['string', true, ''],
|
||||
priority: ['number', true, 0],
|
||||
idleSince: 'date',
|
||||
discoInfo: 'object'
|
||||
discoInfo: 'object',
|
||||
timezoneOffset: 'number'
|
||||
},
|
||||
fetchTimezone: function () {
|
||||
var self = this;
|
||||
|
||||
if (self.timezoneOffset) return;
|
||||
|
||||
app.whenConnected(function () {
|
||||
client.getTime(self.id, function (err, res) {
|
||||
if (err) return;
|
||||
self.timezoneOffset = res.time.tzo;
|
||||
});
|
||||
});
|
||||
},
|
||||
fetchDisco: function () {
|
||||
var self = this;
|
||||
|
||||
if (self.discoInfo) return;
|
||||
|
||||
app.whenConnected(function () {
|
||||
client.getDiscoInfo(self.id, '', function (err, res) {
|
||||
if (err) return;
|
||||
self.discoInfo = res.discoInfo.toJSON();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user