* @return {string} short abbreviation (such as `ru`) for the script's language
*/
LUA_FUNCTION_DEF (textpart, get_language);
+/***
+ * @method text_part:get_mimepart()
+ * Returns the mime part object corresponding to this text part
+ * @return {mimepart} mimepart object
+ */
+LUA_FUNCTION_DEF (textpart, get_mimepart);
/***
* @method text_part:compare_distance(other)
* Calculates the difference to another text part. This function is intended to work with
LUA_INTERFACE_DEF (textpart, is_html),
LUA_INTERFACE_DEF (textpart, get_fuzzy),
LUA_INTERFACE_DEF (textpart, get_language),
+ LUA_INTERFACE_DEF (textpart, get_mimepart),
LUA_INTERFACE_DEF (textpart, compare_distance),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
return 1;
}
+static gint
+lua_textpart_get_mimepart (lua_State * L)
+{
+ struct mime_text_part *part = lua_check_textpart (L);
+ struct mime_part **pmime;
+
+ if (part != NULL) {
+ if (part->mime_part != NULL) {
+ pmime = lua_newuserdata (L, sizeof (struct mime_part *));
+ rspamd_lua_setclass (L, "rspamd{mimepart}", -1);
+ *pmime = part->mime_part;
+
+ return 1;
+ }
+ }
+
+ lua_pushnil (L);
+ return 1;
+}
+
static gint
lua_textpart_compare_distance (lua_State * L)
{