]> source.dussan.org Git - rspamd.git/commitdiff
Allow to set the full result when using rspamd as lda.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Aug 2015 14:55:36 +0000 (15:55 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 25 Aug 2015 14:55:36 +0000 (15:55 +0100)
src/client/rspamc.c

index b4d266bf054b45ba992f9bf25bc0e9652a621ed8..31075e8f315e106793a47c9b8cd4d12a589618d7 100644 (file)
@@ -837,6 +837,14 @@ rspamd_action_from_str (const gchar *data, gint *result)
                        sizeof ("soft reject") - 1) == 0) {
                *result = METRIC_ACTION_SOFT_REJECT;
        }
+       else if (g_ascii_strncasecmp (data, "no_action",
+                       sizeof ("soft_reject") - 1) == 0) {
+               *result = METRIC_ACTION_NOACTION;
+       }
+       else if (g_ascii_strncasecmp (data, "no action",
+                       sizeof ("soft reject") - 1) == 0) {
+               *result = METRIC_ACTION_NOACTION;
+       }
        else {
                return FALSE;
        }
@@ -855,6 +863,7 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input)
        gint act;
        gboolean is_spam = FALSE;
        const gchar *hdr_scanned, *hdr_spam;
+       gchar *json_header, *json_header_encoded;
 
        ar.data = input->str;
        ar.len = input->len;
@@ -898,6 +907,23 @@ rspamc_mime_output (FILE *out, ucl_object_t *result, GString *input)
        g_mime_object_append_header (GMIME_OBJECT (message), "X-Spam-Action",
                        action);
 
+       if (json || raw) {
+               /* We also append json data as a specific header */
+               if (json) {
+                       json_header = ucl_object_emit (result, UCL_EMIT_JSON);
+               }
+               else {
+                       json_header = ucl_object_emit (result, UCL_EMIT_CONFIG);
+               }
+
+               json_header_encoded = rspamd_encode_base64_fold (json_header,
+                               strlen (json_header), 60, NULL);
+               free (json_header);
+               g_mime_object_append_header (GMIME_OBJECT (message), "X-Spam-Result",
+                               json_header_encoded);
+               g_free (json_header_encoded);
+       }
+
        /* Write message */
        stream = g_mime_stream_file_new (out);
        g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);