diff options
author | Kim Alvefur <zash@zash.se> | 2020-09-26 18:07:33 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-09-26 18:07:33 +0200 |
commit | 8c0efc9e55d0980e2ce5872da325724aeaec5dba (patch) | |
tree | 6e7cf6570164fd9e7cd65403868c97911c932176 | |
parent | 3f9988468d11d6e3b94fec0ec1ed4271712bed14 (diff) | |
download | prosody-8c0efc9e55d0980e2ce5872da325724aeaec5dba.tar.gz prosody-8c0efc9e55d0980e2ce5872da325724aeaec5dba.zip |
util.stanza: Get 'by' from context instead
Zash> <error by=?> 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
-rw-r--r-- | spec/util_stanza_spec.lua | 2 | ||||
-rw-r--r-- | util/stanza.lua | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua index c4c1d174..cc32bba9 100644 --- a/spec/util_stanza_spec.lua +++ b/spec/util_stanza_spec.lua @@ -234,7 +234,7 @@ describe("util.stanza", function() 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 --git a/util/stanza.lua b/util/stanza.lua index 2c936a40..3d0d5002 100644 --- a/util/stanza.lua +++ b/util/stanza.lua @@ -459,8 +459,8 @@ local function error_reply(orig, error_type, condition, error_message, error_by) 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 |