Commit 285a6d184e1df61da78c975faef96f36860526f2
1 parent
6dedd76203
Exists in
master
last_response_time_in_secs
Showing 1 changed file with 12 additions and 31 deletions Side-by-side Diff
matrix-util.js
... | ... | @@ -127,45 +127,26 @@ MatrixUtil.prototype._updateLastResponseTime = function(partner) { |
127 | 127 | let matrix = this.matrix; |
128 | 128 | let logger = this.logger; |
129 | 129 | |
130 | - try { | |
131 | - if (!matrix.buddies[partner]['last_outgoing']) { | |
132 | - logger.verbose('No outgoing yet, skip updateLastResponseTime'); | |
133 | - return; | |
134 | - } | |
135 | - | |
136 | - if (!matrix.buddies[partner]['last_outgoing']['last_update_ts']) { | |
137 | - logger.verbose('No outgoing timestamp yet, skip updateLastResponseTime'); | |
138 | - return; | |
139 | - } | |
140 | - } | |
141 | - catch(e) { | |
142 | - logger.warn('Exception when preparing updateLastResponseTime', {err: e}); | |
130 | + if (!matrix.buddies[partner]['last_outgoing']) { | |
131 | + logger.verbose('No outgoing yet, skip updateLastResponseTime'); | |
143 | 132 | return; |
144 | 133 | } |
145 | 134 | |
146 | - try { | |
147 | - if ( | |
148 | - matrix.buddies[partner]['last_incoming'] | |
149 | - && (Number(matrix.buddies[partner]['last_incoming']['last_update_ts']) > Number(matrix.buddies[partner]['last_outgoing']['last_update_ts'])) | |
150 | - ) { | |
151 | - return; | |
152 | - } | |
153 | - } | |
154 | - catch(e) { | |
155 | - logger.warn('Exception when checking if last_incoming > last_outgoing', {err: e}); | |
135 | + if (!matrix.buddies[partner]['last_outgoing']['last_update_ts']) { | |
136 | + logger.verbose('No outgoing timestamp yet, skip updateLastResponseTime'); | |
156 | 137 | return; |
157 | 138 | } |
158 | 139 | |
159 | - | |
160 | - try { | |
161 | - let delta = Date.now() - Number(matrix.buddies[partner]['last_outgoing']['last_update_ts']); | |
162 | - logger.verbose('Response time in ' + delta + 'ms'); | |
163 | - matrix.buddies[partner]['last_response_time'] = Math.round(delta/1000); | |
164 | - } | |
165 | - catch(e) { | |
166 | - logger.warn('Exception when calculating last_response_time', {err: e}); | |
140 | + if ( | |
141 | + matrix.buddies[partner]['last_incoming'] | |
142 | + && (Number(matrix.buddies[partner]['last_incoming']['last_update_ts']) > Number(matrix.buddies[partner]['last_outgoing']['last_update_ts'])) | |
143 | + ) { | |
144 | + return; | |
167 | 145 | } |
168 | 146 | |
147 | + let delta = Date.now() - Number(matrix.buddies[partner]['last_outgoing']['last_update_ts']); | |
148 | + logger.verbose('Response time in ' + delta + 'ms'); | |
149 | + matrix.buddies[partner]['last_response_time_in_secs'] = Math.round(delta/1000); | |
169 | 150 | } |
170 | 151 | |
171 | 152 | MatrixUtil.prototype._updateLastMessage = function(partner, msg, direction) { |