Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 6274:77bdbaec3b7f
plugins/muc/muc.lib: Don't add invite/decline bodies if they already have one
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Fri, 06 Jun 2014 14:34:01 -0400 |
| parents | 7ef064101994 |
| children | d891fa02e5e5 |
comparison
equal
deleted
inserted
replaced
| 6273:7ef064101994 | 6274:77bdbaec3b7f |
|---|---|
| 866 end); | 866 end); |
| 867 | 867 |
| 868 -- Add a plain message for clients which don't support invites | 868 -- Add a plain message for clients which don't support invites |
| 869 module:hook("muc-invite", function(event) | 869 module:hook("muc-invite", function(event) |
| 870 local room, stanza = event.room, event.stanza; | 870 local room, stanza = event.room, event.stanza; |
| 871 local invite = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite"); | 871 if not stanza:get_child("body") then |
| 872 local reason = invite:get_child_text("reason") or ""; | 872 local invite = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite"); |
| 873 stanza:tag("body") | 873 local reason = invite:get_child_text("reason") or ""; |
| 874 :text(invite.attr.from.." invited you to the room "..room.jid..(reason == "" and (" ("..reason..")") or "")) | 874 stanza:tag("body") |
| 875 :up(); | 875 :text(invite.attr.from.." invited you to the room "..room.jid..(reason == "" and (" ("..reason..")") or "")) |
| 876 :up(); | |
| 877 end | |
| 876 end); | 878 end); |
| 877 | 879 |
| 878 function room_mt:handle_mediated_decline(origin, stanza) | 880 function room_mt:handle_mediated_decline(origin, stanza) |
| 879 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline"); | 881 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline"); |
| 880 local declinee = jid_prep(payload.attr.to); | 882 local declinee = jid_prep(payload.attr.to); |
| 904 end | 906 end |
| 905 | 907 |
| 906 -- Add a plain message for clients which don't support declines | 908 -- Add a plain message for clients which don't support declines |
| 907 module:hook("muc-decline", function(event) | 909 module:hook("muc-decline", function(event) |
| 908 local room, stanza = event.room, event.stanza; | 910 local room, stanza = event.room, event.stanza; |
| 909 local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline"); | 911 if not stanza:get_child("body") then |
| 910 local reason = decline:get_child_text("reason") or ""; | 912 local decline = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("decline"); |
| 911 stanza:tag("body") | 913 local reason = decline:get_child_text("reason") or ""; |
| 912 :text(decline.attr.from.." declined your invite to the room "..room.jid..(reason == "" and (" ("..reason..")") or "")) | 914 stanza:tag("body") |
| 913 :up(); | 915 :text(decline.attr.from.." declined your invite to the room "..room.jid..(reason == "" and (" ("..reason..")") or "")) |
| 916 :up(); | |
| 917 end | |
| 914 end); | 918 end); |
| 915 | 919 |
| 916 function room_mt:handle_message_to_room(origin, stanza) | 920 function room_mt:handle_message_to_room(origin, stanza) |
| 917 local type = stanza.attr.type; | 921 local type = stanza.attr.type; |
| 918 if type == "groupchat" then | 922 if type == "groupchat" then |
