mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-12 05:22:13 +00:00
Add msg:set_data()
This method allows replacing the message payload arbitrarily. This is a building block for more advanced and convenient modification operations. refs: https://github.com/KumoCorp/kumomta/issues/117 refs: https://github.com/KumoCorp/kumomta/issues/120
This commit is contained in:
@@ -915,6 +915,10 @@ impl UserData for Message {
|
||||
let data = this.get_data();
|
||||
lua.create_string(&*data)
|
||||
});
|
||||
methods.add_method("set_data", move |_lua, this, data: mlua::String| {
|
||||
this.assign_data(data.as_bytes().to_vec());
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("id", move |_, this, _: ()| Ok(this.id().to_string()));
|
||||
methods.add_method("sender", move |_, this, _: ()| {
|
||||
Ok(this.sender().map_err(any_err)?)
|
||||
|
||||
@@ -2,3 +2,5 @@
|
||||
|
||||
Returns the message body/data as a string.
|
||||
|
||||
See also:
|
||||
* [msg:set_data()](set_data.md)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# `message:set_data(payload)`
|
||||
|
||||
{{since('dev')}}
|
||||
|
||||
Replaces the message body/data completely.
|
||||
It is your responsibility to ensure that the content is well-formed, has
|
||||
canonical CRLF line endings, and uses appropriate transfer-encoding, otherwise
|
||||
the system will misbehave when delivering the message.
|
||||
|
||||
See also:
|
||||
* [msg:get_data()](get_data.md)
|
||||
Reference in New Issue
Block a user