Commit 5fab1040598f4ba640e13fd0e6f535c441b82873
1 parent
45fd1b8867
Exists in
master
accept config on setOptions
Showing 2 changed files with 19 additions and 2 deletions Side-by-side Diff
adaptor-xmpp.js
matrix-util.js
1 | 1 | 'use strict'; |
2 | 2 | |
3 | 3 | var moment = require('moment'); |
4 | + | |
5 | +var config; | |
6 | + | |
4 | 7 | var momentFormat = 'YYYY-MM-DD HH:mm:ss'; |
5 | -var maxHealthyWaitMs = 2 * 60 * 1000; | |
8 | +var defaultMaxHealthyWaitMs = 2 * 60 * 1000; | |
6 | 9 | |
7 | 10 | module.exports = MatrixUtil; |
8 | 11 | |
... | ... | @@ -19,6 +22,11 @@ function _cleanPartnerId(partnerId) { |
19 | 22 | return cleaned; |
20 | 23 | } |
21 | 24 | |
25 | +function getMaxHealthyWaitMs() { | |
26 | + if (!config || !config.globals || !config.globals.max_healthy_wait_ms) { return defaultMaxHealthyWaitMs; } | |
27 | + return config.globals.max_healthy_wait_ms; | |
28 | +} | |
29 | + | |
22 | 30 | function MatrixUtil(options) { |
23 | 31 | if (!options) { |
24 | 32 | console.trace('Undefined options'); |
... | ... | @@ -36,6 +44,12 @@ function MatrixUtil(options) { |
36 | 44 | console.trace("Logger not set"); |
37 | 45 | process.exit(1); |
38 | 46 | } |
47 | + | |
48 | + this.config = options.config; | |
49 | + if (!this.config) new Promise(function(resolve, reject) { | |
50 | + console.trace("Config not set"); | |
51 | + process.exit(1); | |
52 | + }); | |
39 | 53 | } |
40 | 54 | |
41 | 55 | MatrixUtil.prototype.updateBuddyState = function(jid, state, statusText, resource) { |
... | ... | @@ -229,7 +243,6 @@ MatrixUtil.prototype._updateLastMessage = function(partner, msg, direction) { |
229 | 243 | } |
230 | 244 | } |
231 | 245 | |
232 | - | |
233 | 246 | MatrixUtil.prototype.updateLastIncoming = function(partner, msg) { |
234 | 247 | this._updateLastMessage(partner, msg, 'incoming'); |
235 | 248 | } |