Skip to content

Commit

Permalink
Handle incoming presence unavailable updates
Browse files Browse the repository at this point in the history
  • Loading branch information
galfert committed Aug 31, 2021
1 parent e455638 commit c682bf2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/services/sockethub-xmpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ export default class SockethubXmppService extends Service {
channel.addUser(message.actor.displayName);
}
}
} else if (message.actor['@type'] === 'person' && message.actor['@id'].match(/\/(.+)$/)) {
const sockethubActorId = message.actor['@id'];
const targetChannelId = sockethubActorId.match(/^(.+)\//)[1];
const channel = this.coms.getChannel(targetChannelId);
const displayName = sockethubActorId.match(/\/(.+)$/)[1];

if (channel) {
if (message.object.presence === 'unavailable') {
channel.removeUser(displayName);
} else {
channel.addUser(displayName);
}
}
} else {
this.log('xmpp', 'presence update from contact:', message.actor['@id'], message.object.presence, message.object.status);
}
Expand Down

0 comments on commit c682bf2

Please sign in to comment.