From: Vsevolod Stakhov Date: Mon, 17 Dec 2018 14:56:37 +0000 (+0000) Subject: [Minor] Lua_mimepart: Add method to check if part is rfc822 message X-Git-Tag: 1.9.0~410 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=05d0f0b2f23876a11905729275f799b1de2860da;p=rspamd.git [Minor] Lua_mimepart: Add method to check if part is rfc822 message --- 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) {