Skip to content

Commit d026c87

Browse files
author
CleanTalk
committed
Merge pull request #24 from znaeff/master
Fixed message checking.
2 parents eaccb1c + 6eaefc3 commit d026c87

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

CleantalkMod.php

+17-13
Original file line numberDiff line numberDiff line change
@@ -197,30 +197,34 @@ function cleantalk_check_message(&$msgOptions, $topicOptions, $posterOptions)
197197
* @var CleantalkResponse $ct_result CleanTalk API call result
198198
*/
199199
$ct_result = $ct->isAllowMessage($ct_request);
200+
$ct_answer_text = 'CleanTalk: ' . strip_tags($ct_result->comment);
200201

201202
if ($ct_result->errno != 0 && !cleantalk_is_valid_js()) {
202203
cleantalk_log('deny post (errno !=0, invalid js test)' . strip_tags($ct_result->comment));
203-
fatal_error('CleanTalk: ' . strip_tags($ct_result->comment), false);
204+
fatal_error($ct_answer_text, false);
204205
return;
205206
}
206207

207-
if ($ct_result->stop_queue == 1) {
208-
cleantalk_log('stop queue "' . $ct_result->comment . '"');
209-
fatal_error('CleanTalk: ' . strip_tags($ct_result->comment), false);
210-
211-
} elseif ($ct_result->inactive == 1) {
212-
cleantalk_log('inactive message "' . $ct_result->comment . '"');
213-
214-
if ($modSettings['postmod_active']) {
215-
// If post moderation active then set message not approved
216-
$msgOptions['approved'] = 0;
208+
if ($ct_result->allow == 0) {
209+
$msgOptions['cleantalk_check_message_result'] = $ct_result->comment;
210+
if ($modSettings['postmod_active'] || true) {
211+
if ($ct_result->stop_queue == 1) {
212+
cleantalk_log('spam message "' . $ct_result->comment . '"');
213+
fatal_error($ct_answer_text, false);
214+
} else {
215+
// If post moderation active then set message not approved
216+
cleantalk_log('to postmoderation "' . $ct_result->comment . '"');
217+
$msgOptions['approved'] = 0;
218+
}
219+
} else {
220+
cleantalk_log('spam message "' . $ct_result->comment . '"');
221+
fatal_error($ct_answer_text, false);
217222
}
218-
$msgOptions['cleantalk_check_message_result'] = $ct_result->comment;
219-
220223
} else {
221224
// all ok, only logging
222225
cleantalk_log('allow message for "' . $posterOptions['name'] . '"');
223226
}
227+
224228
}
225229

226230
/**

0 commit comments

Comments
 (0)