Add patch-hangouts
[prosody-hacks.git] / patch-hangouts / prosody-0.9.12-presence_void_hangouts.diff
1 --- a/usr/lib/prosody/modules/mod_presence.lua
2 +++ b/usr/lib/prosody/modules/mod_presence.lua
3 @@ -313,6 +312,19 @@
4                 if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to bare JID
5                         return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));
6                 end
7 +
8 +               local from_resource = string.gsub(stanza.attr.from, "^[^/]*/", "", 1);
9 +               if from_resource ~= stanza.attr.from then
10 +                       if string.match(from_resource, "^Messaging%x%x%x%x%x%x%x%x?%x?")
11 +                       or string.match(from_resource, "^messaging%-smgmailw%x%x%x%x%x%x%x%x")
12 +                       or string.match(from_resource, "^messaging%-AChromeExtensionw%x%x%x%x%x%x%x%x")
13 +                       or string.match(from_resource, "^messaging%-TalkGadgetw%x%x%x%x%x%x%x%x")
14 +                       or string.match(from_resource, "^messaging%-lcsw_hangouts%x%x%x%x%x%x%x%x")
15 +                       or string.match(from_resource, "^messaging%-lcsw_hangouts_%x%x%x%x%x%x%x%x") then
16 +                               log("debug", "Voiding presence from: "..stanza.attr.from);
17 +                               stanza.attr.type = "unavailable";
18 +                       end
19 +               end
20
21                 local user = bare_sessions[to];
22                 if user then
23 @@ -338,6 +350,19 @@
24                 return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));
25         end
26
27 +       local from_resource = string.gsub(stanza.attr.from, "^[^/]*/", "", 1);
28 +       if from_resource ~= stanza.attr.from then
29 +               if string.match(from_resource, "^Messaging%x%x%x%x%x%x%x%x?%x?")
30 +               or string.match(from_resource, "^messaging%-smgmailw%x%x%x%x%x%x%x%x")
31 +               or string.match(from_resource, "^messaging%-AChromeExtensionw%x%x%x%x%x%x%x%x")
32 +               or string.match(from_resource, "^messaging%-TalkGadgetw%x%x%x%x%x%x%x%x")
33 +               or string.match(from_resource, "^messaging%-lcsw_hangouts%x%x%x%x%x%x%x%x")
34 +               or string.match(from_resource, "^messaging%-lcsw_hangouts_%x%x%x%x%x%x%x%x") then
35 +                       log("debug", "Voiding presence from: "..stanza.attr.from);
36 +                       stanza.attr.type = "unavailable";
37 +               end
38 +       end
39 +
40         local session = full_sessions[stanza.attr.to];
41         if session then
42                 -- TODO fire post processing event