diff --git a/include/h.h b/include/h.h index 0bbe98c5e..8c511ffa4 100644 --- a/include/h.h +++ b/include/h.h @@ -1393,6 +1393,7 @@ extern LogData *log_data_source(const char *file, int line, const char *function extern LogData *log_data_socket_error(int fd); extern LogData *log_data_link_block(ConfigItem_link *link); extern LogData *log_data_tkl(const char *key, TKL *tkl); +extern LogData *log_data_textanalysis(const char *key, TextAnalysis *ta); extern LogData *log_data_tls_error(void); extern void log_data_free(LogData *d); extern void log_pre_rehash(void); diff --git a/src/log.c b/src/log.c index 58b7da55e..76185bfec 100644 --- a/src/log.c +++ b/src/log.c @@ -728,6 +728,21 @@ LogData *log_data_tkl(const char *key, TKL *tkl) return d; } +LogData *log_data_textanalysis(const char *key, TextAnalysis *ta) +{ + char buf[BUFSIZE]; + LogData *d = safe_alloc(sizeof(LogData)); + json_t *j; + + d->type = LOG_FIELD_OBJECT; + safe_strdup(d->key, key); + d->value.object = j = json_object(); + + json_expand_textanalysis(j, NULL, ta, 1); + + return d; +} + void log_data_free(LogData *d) { if (d->type == LOG_FIELD_STRING) diff --git a/src/modules/tkl.c b/src/modules/tkl.c index 304db10d4..c6764bc76 100644 --- a/src/modules/tkl.c +++ b/src/modules/tkl.c @@ -5416,13 +5416,18 @@ static void match_spamfilter_hit(Client *client, const char *str_in, const char log_data_string("_space", destination ? " " : ""), log_data_string("destination", destination ? destination : "")); } else { + // Yeah we are re-running the text analysis. + TextAnalysis textanalysis; + memset(&textanalysis, 0, sizeof(textanalysis)); + RunHook(HOOKTYPE_ANALYZE_TEXT, client, str, &textanalysis); unreal_log(ULOG_INFO, "tkl", "SPAMFILTER_MATCH", client, "[Spamfilter] $client.details matches filter '$tkl': [cmd: $command$_space$destination: '$str'] [reason: $tkl.reason] [action: $tkl.ban_action]", log_data_tkl("tkl", tkl), log_data_string("command", cmd), log_data_string("_space", destination ? " " : ""), log_data_string("destination", destination ? destination : ""), - log_data_string("str", str)); + log_data_string("str", str), + log_data_textanalysis("textanalysis", &textanalysis)); *content_revealed = 1; } diff --git a/src/parse.c b/src/parse.c index ce80d510e..25caf3bac 100644 --- a/src/parse.c +++ b/src/parse.c @@ -561,7 +561,7 @@ static void parse2(Client *cptr, Client **fromptr, MessageTag *mtags, int mtags_ { memset(&text_analysis_storage, 0, sizeof(text_analysis_storage)); clictx.textanalysis = &text_analysis_storage; - RunHook(HOOKTYPE_ANALYZE_TEXT, from, para[i-1], clictx.textanalysis); // is para[i] correct? probably not? -1 ? safety check? + RunHook(HOOKTYPE_ANALYZE_TEXT, from, para[i-1], clictx.textanalysis); } /* Now ready to execute the command */