commit 05d0f0b: [Minor] Lua_mimepart: Add method to check if part is rfc822 message
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Dec 27 18:28:10 UTC 2018
Author: Vsevolod Stakhov
Date: 2018-12-17 14:56:37 +0000
URL: https://github.com/rspamd/rspamd/commit/05d0f0b2f23876a11905729275f799b1de2860da
[Minor] Lua_mimepart: Add method to check if part is rfc822 message
---
src/lua/lua_mimepart.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index c45030791..09ccdf47d 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -421,7 +421,12 @@ LUA_FUNCTION_DEF (mimepart, get_archive);
* @return {bool} true if a part is is a multipart part
*/
LUA_FUNCTION_DEF (mimepart, is_multipart);
-
+/***
+ * @method mime_part:is_message()
+ * Returns true if mime part is a message part (message/rfc822)
+ * @return {bool} true if a part is is a message part
+ */
+LUA_FUNCTION_DEF (mimepart, is_message);
/***
* @method mime_part:get_boundary()
* Returns boundary for a part (extracted from parent multipart for normal parts and
@@ -504,6 +509,7 @@ static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, is_archive),
LUA_INTERFACE_DEF (mimepart, get_archive),
LUA_INTERFACE_DEF (mimepart, is_multipart),
+ LUA_INTERFACE_DEF (mimepart, is_message),
LUA_INTERFACE_DEF (mimepart, get_children),
LUA_INTERFACE_DEF (mimepart, is_text),
LUA_INTERFACE_DEF (mimepart, is_broken),
@@ -1509,6 +1515,21 @@ lua_mimepart_is_multipart (lua_State * L)
return 1;
}
+static gint
+lua_mimepart_is_message (lua_State * L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_mime_part *part = lua_check_mimepart (L);
+
+ if (part == NULL) {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ lua_pushboolean (L, IS_CT_MESSAGE (part->ct) ? true : false);
+
+ return 1;
+}
+
static gint
lua_mimepart_is_attachment (lua_State * L)
{
More information about the Commits
mailing list