From c682bf28dbac4bb11929518d96258ea6a54eea3a Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Tue, 31 Aug 2021 19:58:48 +0200 Subject: [PATCH] Handle incoming presence unavailable updates --- app/services/sockethub-xmpp.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/services/sockethub-xmpp.js b/app/services/sockethub-xmpp.js index d1bfed73..2b4cc7e8 100644 --- a/app/services/sockethub-xmpp.js +++ b/app/services/sockethub-xmpp.js @@ -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); }