Software /
code /
prosody
Comparison
util/stanza.lua @ 11084:5e09a3389adb
util.stanza: Support inclusion of <gone> URI from util.error object
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 26 Sep 2020 17:30:47 +0200 |
parent | 11083:4d12a6785531 |
child | 11085:5705d151ea11 |
comparison
equal
deleted
inserted
replaced
11083:4d12a6785531 | 11084:5e09a3389adb |
---|---|
453 elseif orig.attr.type == "error" then | 453 elseif orig.attr.type == "error" then |
454 error("bad argument to error_reply: got stanza of type error which must not be replied to"); | 454 error("bad argument to error_reply: got stanza of type error which must not be replied to"); |
455 end | 455 end |
456 local t = reply(orig); | 456 local t = reply(orig); |
457 t.attr.type = "error"; | 457 t.attr.type = "error"; |
458 local extra; | |
458 if type(error_type) == "table" then -- an util.error or similar object | 459 if type(error_type) == "table" then -- an util.error or similar object |
459 if type(error_type.extra) == "table" then | 460 if type(error_type.extra) == "table" then |
460 if type(error_type.extra.by) == "string" then error_by = error_type.extra.by; end | 461 extra = error_type.extra; |
462 if type(extra.by) == "string" then error_by = extra.by; end | |
461 end | 463 end |
462 error_type, condition, error_message = error_type.type, error_type.condition, error_type.text; | 464 error_type, condition, error_message = error_type.type, error_type.condition, error_type.text; |
463 end | 465 end |
464 if t.attr.from == error_by then | 466 if t.attr.from == error_by then |
465 error_by = nil; | 467 error_by = nil; |
466 end | 468 end |
467 t:tag("error", {type = error_type, by = error_by}) --COMPAT: Some day xmlns:stanzas goes here | 469 t:tag("error", {type = error_type, by = error_by}) --COMPAT: Some day xmlns:stanzas goes here |
468 :tag(condition, xmpp_stanzas_attr):up(); | 470 :tag(condition, xmpp_stanzas_attr); |
471 if extra and condition == "gone" and type(extra.uri) == "string" then | |
472 t:text(extra.uri); | |
473 end | |
474 t:up(); | |
469 if error_message then t:text_tag("text", error_message, xmpp_stanzas_attr); end | 475 if error_message then t:text_tag("text", error_message, xmpp_stanzas_attr); end |
470 return t; -- stanza ready for adding app-specific errors | 476 return t; -- stanza ready for adding app-specific errors |
471 end | 477 end |
472 | 478 |
473 local function presence(attr) | 479 local function presence(attr) |