Allow marking any post illegal
using its md5 hash if it doesn't have a phash
This commit is contained in:
parent
b8aab0c258
commit
efbc8fa477
34
script.js
34
script.js
|
@ -570,15 +570,11 @@ function linkToBoard(website_name, board_name, thread_id) {
|
|||
}
|
||||
}
|
||||
|
||||
function attachmentCanBeMarkedIllegal(attachment) {
|
||||
return attachment.phash != null && !attachment.illegal;
|
||||
}
|
||||
|
||||
function shouldDisplayMarkIllegalButton(post) {
|
||||
let result = false;
|
||||
|
||||
for (let attachment of (post.known_spam_post_attachment || [])) {
|
||||
result = result || attachmentCanBeMarkedIllegal(attachment);
|
||||
result = result || !attachment.illegal;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -594,7 +590,7 @@ function isIllegal(post) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function onClickMarkIllegal(phashes, e) {
|
||||
function onClickMarkIllegal(phashes, md5_hashes, e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
|
@ -616,6 +612,10 @@ function onClickMarkIllegal(phashes, e) {
|
|||
console.log('onClickMarkIllegal', typeof p, p);
|
||||
url.searchParams.append('phash', p);
|
||||
});
|
||||
md5_hashes.forEach(function(h) {
|
||||
console.log('onClickMarkIllegal', typeof h, h);
|
||||
url.searchParams.append('md5_hash', h);
|
||||
});
|
||||
|
||||
await post(url.toString(), null, cancel)
|
||||
.then(function() {
|
||||
|
@ -673,7 +673,10 @@ function renderPostElem(post, btn_delete=false) {
|
|||
console.log('renderPostElem POST:', post);
|
||||
|
||||
if (post.website_name != null) {
|
||||
console.log("renderPostElem. post.website_name:", post.website_name);
|
||||
console.log("calling linkToBoard", post.website_name, post.board_name, post.thread_id);
|
||||
const link_url = linkToBoard(post.website_name, post.board_name, post.thread_id);
|
||||
console.log("link_url:", link_url);
|
||||
const boardlink_a = document.createElement('a');
|
||||
/*
|
||||
* TODO: The link to the board is way too wide in the UI!
|
||||
|
@ -695,13 +698,22 @@ function renderPostElem(post, btn_delete=false) {
|
|||
mark_illegal.appendChild(text('Mark Illegal'));
|
||||
mark_illegal.setAttribute('title', 'Permanently delete associated pictures and thumbnails but keep metadata for future matching');
|
||||
|
||||
const phashes = (post.known_spam_post_attachment || [])
|
||||
.map(function(p) {
|
||||
return bufferToHex(unpackBytes(BigInt(p.phash)));
|
||||
});
|
||||
const [phashes, md5_hashes] = (post.known_spam_post_attachment || [])
|
||||
.reduce(
|
||||
function(results_tuple, p) {
|
||||
if (p.hash != null) {
|
||||
results_tuple[0].push(bufferToHex(unpackBytes(BigInt(p.phash))));
|
||||
} else {
|
||||
results_tuple[1].push(p.md5_sum);
|
||||
}
|
||||
|
||||
return results_tuple;
|
||||
},
|
||||
[[],[]]
|
||||
);
|
||||
|
||||
mark_illegal.addEventListener('click',
|
||||
onClickMarkIllegal.bind(this, phashes));
|
||||
onClickMarkIllegal.bind(this, phashes, md5_hashes));
|
||||
|
||||
postHeader.appendChild(mark_illegal);
|
||||
} else if (isIllegal(post)) {
|
||||
|
|
Loading…
Reference in New Issue