Compare commits

...

3 Commits

Author SHA1 Message Date
towards-a-new-leftypol 814b1779b4 New attachment redacted text image 2024-12-29 05:44:38 -05:00
towards-a-new-leftypol d8be87a2f9 Fix building post request url to /illegal 2024-12-29 10:29:29 +00:00
towards-a-new-leftypol efbc8fa477 Allow marking any post illegal
using its md5 hash if it doesn't have a phash
2024-12-29 10:18:36 +00:00
4 changed files with 26 additions and 14 deletions

BIN
attachment_redacted.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -520,7 +520,7 @@ function mkSpamImgElement(img_description) {
console.log('img_description.illegal', img_description.illegal);
if (illegal) {
thumb_url = "/static/redacted.jpg";
thumb_url = "/static/image_redacted.jpg";
} else if (MIME_THUMBNAILS[mime] != null) {
thumb_url = MIME_THUMBNAILS[mime];
} else {
@ -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,11 +590,11 @@ function isIllegal(post) {
return result;
}
function onClickMarkIllegal(phashes, e) {
function onClickMarkIllegal(phashes, md5_hashes, e) {
e.stopPropagation();
e.preventDefault();
console.log('CLICK', phashes, e.target.hash);
console.log('CLICK', phashes, md5_hashes, e.target.hash);
const img_elems = document.querySelectorAll('img');
@ -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_hash);
}
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)) {

View File

@ -1,7 +1,7 @@
{
"postgrest_subdomain": "pgrest-spam",
"postgrest_url": "http://192.168.4.6:3000",
"postgrest_url": "http://10.4.0.96:3000",
"postgrest_url": "http://192.168.4.6:3000",
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A",
"website_urls": {
"leftychan.net": "https://leftychan.net",