2020-06-06 13:25:32 +02:00
|
|
|
jQuery(function($){
|
|
|
|
var qitem = $('legend').data('hash');
|
|
|
|
var qError = $("#qid_error");
|
|
|
|
$.ajax({
|
|
|
|
url: '/inc/ajax/qitem_details.php',
|
|
|
|
data: { hash: qitem },
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(data){
|
|
|
|
$('[data-id="qitems_single"]').each(function(index) {
|
|
|
|
$(this).attr("data-item", qitem);
|
|
|
|
});
|
|
|
|
$('#qid_detail_subj').text(data.subject);
|
|
|
|
$('#qid_detail_hfrom').text(data.header_from);
|
|
|
|
$('#qid_detail_efrom').text(data.env_from);
|
2020-11-06 15:26:48 +02:00
|
|
|
$('#qid_detail_score').html('');
|
2020-06-06 13:25:32 +02:00
|
|
|
$('#qid_detail_symbols').html('');
|
2020-11-06 15:26:48 +02:00
|
|
|
$('#qid_detail_recipients').html('');
|
2020-10-24 16:27:31 +02:00
|
|
|
$('#qid_detail_fuzzy').html('');
|
2020-11-06 15:26:48 +02:00
|
|
|
if (typeof data.fuzzy_hashes === 'object' && data.fuzzy_hashes !== null && data.fuzzy_hashes.length !== 0) {
|
2020-10-24 16:27:31 +02:00
|
|
|
$.each(data.fuzzy_hashes, function (index, value) {
|
|
|
|
$('#qid_detail_fuzzy').append('<p style="font-family:monospace">' + value + '</p>');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('#qid_detail_fuzzy').append('-');
|
|
|
|
}
|
2020-06-06 13:25:32 +02:00
|
|
|
if (typeof data.symbols !== 'undefined') {
|
|
|
|
data.symbols.sort(function (a, b) {
|
|
|
|
if (a.score === 0) return 1
|
|
|
|
if (b.score === 0) return -1
|
|
|
|
if (b.score < 0 && a.score < 0) {
|
|
|
|
return a.score - b.score
|
|
|
|
}
|
|
|
|
if (b.score > 0 && a.score > 0) {
|
|
|
|
return b.score - a.score
|
|
|
|
}
|
|
|
|
return b.score - a.score
|
|
|
|
})
|
|
|
|
$.each(data.symbols, function (index, value) {
|
|
|
|
var highlightClass = ''
|
|
|
|
if (value.score > 0) highlightClass = 'negative'
|
|
|
|
else if (value.score < 0) highlightClass = 'positive'
|
|
|
|
else highlightClass = 'neutral'
|
2022-04-01 08:25:47 +02:00
|
|
|
$('#qid_detail_symbols').append('<span data-bs-toggle="tooltip" class="rspamd-symbol ' + highlightClass + '" title="' + (value.options ? value.options.join(', ') : '') + '">' + value.name + ' (<span class="score">' + value.score + '</span>)</span>');
|
2020-06-06 13:25:32 +02:00
|
|
|
});
|
2022-04-01 08:25:47 +02:00
|
|
|
$('[data-bs-toggle="tooltip"]').tooltip()
|
2020-06-06 13:25:32 +02:00
|
|
|
}
|
2020-11-06 15:26:48 +02:00
|
|
|
if (typeof data.score !== 'undefined' && typeof data.action !== 'undefined') {
|
|
|
|
if (data.action === "add header") {
|
2022-04-01 08:25:47 +02:00
|
|
|
$('#qid_detail_score').append('<span class="label-rspamd-action badge fs-5 bg-warning"><b>' + data.score + '</b> - ' + lang.junk_folder + '</span>');
|
2020-11-13 22:26:42 +02:00
|
|
|
} else if (data.action === "reject") {
|
2022-04-01 08:25:47 +02:00
|
|
|
$('#qid_detail_score').append('<span class="label-rspamd-action badge fs-5 bg-danger"><b>' + data.score + '</b> - ' + lang.rejected + '</span>');
|
2020-11-13 22:26:42 +02:00
|
|
|
} else if (data.action === "rewrite subject") {
|
2022-04-01 08:25:47 +02:00
|
|
|
$('#qid_detail_score').append('<span class="label-rspamd-action badge fs-5 bg-warning"><b>' + data.score + '</b> - ' + lang.rewrite_subject + '</span>');
|
2020-11-06 15:26:48 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-06 13:25:32 +02:00
|
|
|
if (typeof data.recipients !== 'undefined') {
|
|
|
|
$.each(data.recipients, function(index, value) {
|
|
|
|
var elem = $('<span class="mail-address-item"></span>');
|
2020-06-07 10:45:40 +02:00
|
|
|
elem.text(value.address + ' (' + value.type.toUpperCase() + ')');
|
2020-06-06 13:25:32 +02:00
|
|
|
$('#qid_detail_recipients').append(elem);
|
|
|
|
});
|
|
|
|
}
|
2020-11-09 15:42:26 +02:00
|
|
|
},
|
|
|
|
error: function(data){
|
|
|
|
if (typeof data.error !== 'undefined') {
|
|
|
|
qError.text("Error loading quarantine item");
|
|
|
|
qError.show();
|
|
|
|
}
|
2020-06-06 13:25:32 +02:00
|
|
|
}
|
|
|
|
});
|
2020-11-13 22:26:42 +02:00
|
|
|
});
|