Compare commits
3 Commits
b8aab0c258
...
814b1779b4
Author | SHA1 | Date |
---|---|---|
towards-a-new-leftypol | 814b1779b4 | |
towards-a-new-leftypol | d8be87a2f9 | |
towards-a-new-leftypol | efbc8fa477 |
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
38
script.js
38
script.js
|
@ -520,7 +520,7 @@ function mkSpamImgElement(img_description) {
|
||||||
console.log('img_description.illegal', img_description.illegal);
|
console.log('img_description.illegal', img_description.illegal);
|
||||||
|
|
||||||
if (illegal) {
|
if (illegal) {
|
||||||
thumb_url = "/static/redacted.jpg";
|
thumb_url = "/static/image_redacted.jpg";
|
||||||
} else if (MIME_THUMBNAILS[mime] != null) {
|
} else if (MIME_THUMBNAILS[mime] != null) {
|
||||||
thumb_url = MIME_THUMBNAILS[mime];
|
thumb_url = MIME_THUMBNAILS[mime];
|
||||||
} else {
|
} 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) {
|
function shouldDisplayMarkIllegalButton(post) {
|
||||||
let result = false;
|
let result = false;
|
||||||
|
|
||||||
for (let attachment of (post.known_spam_post_attachment || [])) {
|
for (let attachment of (post.known_spam_post_attachment || [])) {
|
||||||
result = result || attachmentCanBeMarkedIllegal(attachment);
|
result = result || !attachment.illegal;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -594,11 +590,11 @@ function isIllegal(post) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickMarkIllegal(phashes, e) {
|
function onClickMarkIllegal(phashes, md5_hashes, e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
console.log('CLICK', phashes, e.target.hash);
|
console.log('CLICK', phashes, md5_hashes, e.target.hash);
|
||||||
|
|
||||||
const img_elems = document.querySelectorAll('img');
|
const img_elems = document.querySelectorAll('img');
|
||||||
|
|
||||||
|
@ -616,6 +612,10 @@ function onClickMarkIllegal(phashes, e) {
|
||||||
console.log('onClickMarkIllegal', typeof p, p);
|
console.log('onClickMarkIllegal', typeof p, p);
|
||||||
url.searchParams.append('phash', 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)
|
await post(url.toString(), null, cancel)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
@ -673,7 +673,10 @@ function renderPostElem(post, btn_delete=false) {
|
||||||
console.log('renderPostElem POST:', post);
|
console.log('renderPostElem POST:', post);
|
||||||
|
|
||||||
if (post.website_name != null) {
|
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);
|
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');
|
const boardlink_a = document.createElement('a');
|
||||||
/*
|
/*
|
||||||
* TODO: The link to the board is way too wide in the UI!
|
* 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.appendChild(text('Mark Illegal'));
|
||||||
mark_illegal.setAttribute('title', 'Permanently delete associated pictures and thumbnails but keep metadata for future matching');
|
mark_illegal.setAttribute('title', 'Permanently delete associated pictures and thumbnails but keep metadata for future matching');
|
||||||
|
|
||||||
const phashes = (post.known_spam_post_attachment || [])
|
const [phashes, md5_hashes] = (post.known_spam_post_attachment || [])
|
||||||
.map(function(p) {
|
.reduce(
|
||||||
return bufferToHex(unpackBytes(BigInt(p.phash)));
|
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',
|
mark_illegal.addEventListener('click',
|
||||||
onClickMarkIllegal.bind(this, phashes));
|
onClickMarkIllegal.bind(this, phashes, md5_hashes));
|
||||||
|
|
||||||
postHeader.appendChild(mark_illegal);
|
postHeader.appendChild(mark_illegal);
|
||||||
} else if (isIllegal(post)) {
|
} else if (isIllegal(post)) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"postgrest_subdomain": "pgrest-spam",
|
"postgrest_subdomain": "pgrest-spam",
|
||||||
"postgrest_url": "http://192.168.4.6:3000",
|
|
||||||
"postgrest_url": "http://10.4.0.96:3000",
|
"postgrest_url": "http://10.4.0.96:3000",
|
||||||
|
"postgrest_url": "http://192.168.4.6:3000",
|
||||||
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A",
|
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic3BhbV9ub3RpY2VyIn0.j6-6HSBh-Wf5eQovT9cF1ZCNuxkQOqzBFtE3C8aTG3A",
|
||||||
"website_urls": {
|
"website_urls": {
|
||||||
"leftychan.net": "https://leftychan.net",
|
"leftychan.net": "https://leftychan.net",
|
||||||
|
|
Loading…
Reference in New Issue