Comparison

plugins/muc/muc.lib.lua @ 9819:11671a2e07a9 0.11

MUC: Add error message to error bounces when not joined to room
author Matthew Wild <mwild1@gmail.com>
date Mon, 04 Feb 2019 09:27:43 +0000
parent 9718:81ef96368bff
child 9820:87a1742f928d
child 10211:224e681c4db2
comparison
equal deleted inserted replaced
9817:7aad9eb7f050 9819:11671a2e07a9
725 stanza.attr.from, stanza.attr.to, stanza.attr.id = from, to, id; 725 stanza.attr.from, stanza.attr.to, stanza.attr.id = from, to, id;
726 return true; 726 return true;
727 else -- Type is "get" or "set" 727 else -- Type is "get" or "set"
728 local current_nick = self:get_occupant_jid(from); 728 local current_nick = self:get_occupant_jid(from);
729 if not current_nick then 729 if not current_nick then
730 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 730 origin.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not currently connected to this chat"));
731 return true; 731 return true;
732 end 732 end
733 if not occupant then -- recipient not in room 733 if not occupant then -- recipient not in room
734 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Recipient not in room")); 734 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Recipient not in room"));
735 return true; 735 return true;
758 local from, to = stanza.attr.from, stanza.attr.to; 758 local from, to = stanza.attr.from, stanza.attr.to;
759 local current_nick = self:get_occupant_jid(from); 759 local current_nick = self:get_occupant_jid(from);
760 local type = stanza.attr.type; 760 local type = stanza.attr.type;
761 if not current_nick then -- not in room 761 if not current_nick then -- not in room
762 if type ~= "error" then 762 if type ~= "error" then
763 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 763 origin.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not currently connected to this chat"));
764 end 764 end
765 return true; 765 return true;
766 end 766 end
767 if type == "groupchat" then -- groupchat messages not allowed in PM 767 if type == "groupchat" then -- groupchat messages not allowed in PM
768 origin.send(st.error_reply(stanza, "modify", "bad-request")); 768 origin.send(st.error_reply(stanza, "modify", "bad-request"));
1055 1055
1056 -- Role check 1056 -- Role check
1057 module:hook("muc-occupant-groupchat", function(event) 1057 module:hook("muc-occupant-groupchat", function(event)
1058 local role_rank = valid_roles[event.occupant and event.occupant.role or "none"]; 1058 local role_rank = valid_roles[event.occupant and event.occupant.role or "none"];
1059 if role_rank <= valid_roles.none then 1059 if role_rank <= valid_roles.none then
1060 event.origin.send(st.error_reply(event.stanza, "cancel", "not-acceptable")); 1060 event.origin.send(st.error_reply(event.stanza, "cancel", "not-acceptable", "You are not currently connected to this chat"));
1061 return true; 1061 return true;
1062 elseif role_rank <= valid_roles.visitor then 1062 elseif role_rank <= valid_roles.visitor then
1063 event.origin.send(st.error_reply(event.stanza, "auth", "forbidden")); 1063 event.origin.send(st.error_reply(event.stanza, "auth", "forbidden"));
1064 return true; 1064 return true;
1065 end 1065 end