Commit f74e65523922f394df776bc8fc51bc13a8466817

Authored by Adhidarma Hadiwinoto
1 parent ce0040f97e
Exists in master

put buddy state to matrix

Showing 1 changed file with 17 additions and 0 deletions Side-by-side Diff

... ... @@ -36,6 +36,23 @@ function onSubscribe(sender) {
36 36  
37 37 function onBuddy(jid, state, statusText, resource) {
38 38 logger.verbose('Buddy state change', {jid: jid, state: state, statusText: statusText, resource: resource});
  39 +
  40 + if (!matrix) {
  41 + return;
  42 + }
  43 +
  44 + if (!matrix.buddies) {
  45 + matrix.buddies = {};
  46 + }
  47 +
  48 + if (!matrix.buddies[jid]) {
  49 + matrix.buddies[jid] = {};
  50 + }
  51 +
  52 + matrix.buddies[jid][resource] = {
  53 + state: state,
  54 + statusText: statusText
  55 + }
39 56 }
40 57  
41 58 function init(_username, _password, _logger, _callbacks) {