Let Google Hangouts contacts appear offline nohangouts-0.8.2
authornorly <ny-git@enpas.org>
Wed, 13 Jul 2016 22:37:21 +0000 (00:37 +0200)
committernorly <ny-git@enpas.org>
Wed, 13 Jul 2016 22:37:21 +0000 (00:37 +0200)
plugins/mod_presence.lua

index 6d039d83f9862bb1e9a7dc8861c9e778d64a1d5c..de1ea5338debf036a45f07f15575aae10bb4f56c 100644 (file)
@@ -300,6 +300,19 @@ module:hook("presence/bare", function(data)
                if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID
                        return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));
                end
+
+               local from_resource = string.gsub(stanza.attr.from, "^[^/]*/", "", 1);
+               if from_resource ~= stanza.attr.from then
+                       if string.match(from_resource, "^Messaging%x%x%x%x%x%x%x%x?%x?")
+                       or string.match(from_resource, "^messaging%-smgmailw%x%x%x%x%x%x%x%x")
+                       or string.match(from_resource, "^messaging%-AChromeExtensionw%x%x%x%x%x%x%x%x")
+                       or string.match(from_resource, "^messaging%-TalkGadgetw%x%x%x%x%x%x%x%x")
+                       or string.match(from_resource, "^messaging%-lcsw_hangouts%x%x%x%x%x%x%x%x")
+                       or string.match(from_resource, "^messaging%-lcsw_hangouts_%x%x%x%x%x%x%x%x") then
+                               log("debug", "Voiding presence from: "..stanza.attr.from);
+                               stanza.attr.type = "unavailable";
+                       end
+               end
        
                local user = bare_sessions[to];
                if user then
@@ -325,6 +338,19 @@ module:hook("presence/full", function(data)
                return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));
        end
 
+       local from_resource = string.gsub(stanza.attr.from, "^[^/]*/", "", 1);
+       if from_resource ~= stanza.attr.from then
+               if string.match(from_resource, "^Messaging%x%x%x%x%x%x%x%x?%x?")
+               or string.match(from_resource, "^messaging%-smgmailw%x%x%x%x%x%x%x%x")
+               or string.match(from_resource, "^messaging%-AChromeExtensionw%x%x%x%x%x%x%x%x")
+               or string.match(from_resource, "^messaging%-TalkGadgetw%x%x%x%x%x%x%x%x")
+               or string.match(from_resource, "^messaging%-lcsw_hangouts%x%x%x%x%x%x%x%x")
+               or string.match(from_resource, "^messaging%-lcsw_hangouts_%x%x%x%x%x%x%x%x") then
+                       log("debug", "Voiding presence from: "..stanza.attr.from);
+                       stanza.attr.type = "unavailable";
+               end
+       end
+
        local session = full_sessions[stanza.attr.to];
        if session then
                -- TODO fire post processing event