comparison plugins/mod_external_services.lua @ 12431:95f33a006c03 0.12

mod_external_services: Move error message to correct place (fix #1725) This message was misplaced in c4599a7c534c when the @type and @host check was introduced.
author Kim Alvefur <zash@zash.se>
date Wed, 23 Mar 2022 15:29:01 +0100
parents f752427a5214
children 4d75663d1552
comparison
equal deleted inserted replaced
12427:018ac691ee22 12431:95f33a006c03
190 local function handle_credentials(event) 190 local function handle_credentials(event)
191 local origin, stanza = event.origin, event.stanza; 191 local origin, stanza = event.origin, event.stanza;
192 local action = stanza.tags[1]; 192 local action = stanza.tags[1];
193 193
194 if origin.type ~= "c2s" then 194 if origin.type ~= "c2s" then
195 origin.send(st.error_reply(stanza, "auth", "forbidden", "The 'port' and 'type' attributes are required.")); 195 origin.send(st.error_reply(stanza, "auth", "forbidden"));
196 return true; 196 return true;
197 end 197 end
198 198
199 local services = get_services(); 199 local services = get_services();
200 services:filter(function (item) 200 services:filter(function (item)
202 end) 202 end)
203 203
204 local requested_credentials = set.new(); 204 local requested_credentials = set.new();
205 for service in action:childtags("service") do 205 for service in action:childtags("service") do
206 if not service.attr.type or not service.attr.host then 206 if not service.attr.type or not service.attr.host then
207 origin.send(st.error_reply(stanza, "modify", "bad-request")); 207 origin.send(st.error_reply(stanza, "modify", "bad-request", "The 'port' and 'type' attributes are required."));
208 return true; 208 return true;
209 end 209 end
210 210
211 requested_credentials:add(string.format("%s:%s:%d", service.attr.type, service.attr.host, 211 requested_credentials:add(string.format("%s:%s:%d", service.attr.type, service.attr.host,
212 tonumber(service.attr.port) or 0)); 212 tonumber(service.attr.port) or 0));