# HG changeset patch # User Kim Alvefur # Date 1601136453 -7200 # Node ID 5705d151ea11908b4117d400a50397ebbcc02a1d # Parent 5e09a3389adb2bf8abd0ff41a53bb1edca04fd95 util.stanza: Get 'by' from context instead Zash> should go where? extra.by? context? source? Zash> In Prosody this would usually be module.host or a bare user/room JID MattJ> Zash: context MattJ> context.by, basically the opposite of context.actor diff -r 5e09a3389adb -r 5705d151ea11 spec/util_stanza_spec.lua --- a/spec/util_stanza_spec.lua Sat Sep 26 17:30:47 2020 +0200 +++ b/spec/util_stanza_spec.lua Sat Sep 26 18:07:33 2020 +0200 @@ -234,7 +234,7 @@ it("should accept util.error objects", function () local s = st.message({ to = "touser", from = "fromuser", id = "123", type = "chat" }, "Hello"); - local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork", extra = { by = "this.test" } }); + local e = errors.new({ type = "modify", condition = "not-acceptable", text = "Bork bork bork" }, { by = "this.test" }); local r = st.error_reply(s, e); assert.are.equal(r.name, s.name); diff -r 5e09a3389adb -r 5705d151ea11 util/stanza.lua --- a/util/stanza.lua Sat Sep 26 17:30:47 2020 +0200 +++ b/util/stanza.lua Sat Sep 26 18:07:33 2020 +0200 @@ -459,8 +459,8 @@ if type(error_type) == "table" then -- an util.error or similar object if type(error_type.extra) == "table" then extra = error_type.extra; - if type(extra.by) == "string" then error_by = extra.by; end end + if type(error_type.context) == "table" and type(error_type.context.by) == "string" then error_by = error_type.context.by; end error_type, condition, error_message = error_type.type, error_type.condition, error_type.text; end if t.attr.from == error_by then