Auto-tag bot-protected clips with needs-reclip
This commit is contained in:
1 parent
906b18e7a6
commit
28d397dea3
2 files changed
+22
-3
No files matched your search
@@ -276,7 +276,11 @@ export async function POST(req: NextRequest) {
|
||||
stripHtmlToText(finalHtml).slice(0, 60).trim() ||
|
||||
(uploadedFiles[0]?.name ? `Attachment: ${uploadedFiles[0].name}` : 'Shared Note');
|
||||
|
||||
const tagIds = await getOrCreateTagIds(['inbox', 'share'], userId);
|
||||
const tagNames = ['inbox', 'share'];
|
||||
if (url && !text && uploadedFiles.length === 0) {
|
||||
tagNames.push('needs-reclip');
|
||||
}
|
||||
const tagIds = await getOrCreateTagIds(tagNames, userId);
|
||||
|
||||
const note = await prisma.note.create({
|
||||
data: {
|
||||
|
||||
+17
-2
@@ -82,8 +82,14 @@ export async function getOrCreateTagIds(
|
||||
where: { userId, name: { equals: name, mode: 'insensitive' } },
|
||||
});
|
||||
if (!tag) {
|
||||
const color = name.toLowerCase() === 'needs-reclip' ? '#f59e0b' : '#00a82d';
|
||||
tag = await prisma.tag.create({
|
||||
data: { userId, name },
|
||||
data: { userId, name, color },
|
||||
});
|
||||
} else if (name.toLowerCase() === 'needs-reclip' && tag.color === '#00a82d') {
|
||||
tag = await prisma.tag.update({
|
||||
where: { id: tag.id },
|
||||
data: { color: '#f59e0b' },
|
||||
});
|
||||
}
|
||||
ids.push(tag.id);
|
||||
@@ -866,14 +872,23 @@ export async function clipUrlToNote(
|
||||
contentHtml.includes('Just a moment...') ||
|
||||
contentHtml.includes('captcha-delivery.com') ||
|
||||
contentHtml.includes('challenge-platform') ||
|
||||
contentHtml.includes('Attention Required! | Cloudflare') ||
|
||||
contentHtml.includes('Cloudflare Ray ID') ||
|
||||
contentHtml.includes('datadome') ||
|
||||
title === 'Just a moment...' ||
|
||||
title === 'Attention Required! | Cloudflare' ||
|
||||
(contentHtml.length < 300 && contentHtml.includes('enable JS'));
|
||||
|
||||
const tagsToApply = [...(options.tags || ['web-clip'])];
|
||||
|
||||
if (isBotChallenge) {
|
||||
if (title === 'Just a moment...' || title.includes('.com') || title.includes('enable JS')) {
|
||||
title = options.title?.trim() || url;
|
||||
}
|
||||
contentHtml = `<p><strong><a href="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(title)}</a></strong></p>\n<p><em>(This site is protected by bot verification. To clip full article text and graphics, use the Everclone Web Clipper extension directly from your browser tab.)</em></p>\n<p>Source: <a href="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(url)}</a></p>`;
|
||||
if (!tagsToApply.includes('needs-reclip')) {
|
||||
tagsToApply.push('needs-reclip');
|
||||
}
|
||||
} else if (shouldPrependHeroImage(contentHtml, heroImgSrc)) {
|
||||
contentHtml = `<p><img src="${escapeHtml(heroImgSrc!)}" alt="${escapeHtml(title)}" /></p>\n${contentHtml}`;
|
||||
}
|
||||
@@ -881,7 +896,7 @@ export async function clipUrlToNote(
|
||||
const userId = await getCurrentUserId();
|
||||
const contentText = stripHtmlToText(contentHtml);
|
||||
const excerpt = makeExcerpt(article?.excerpt || contentText);
|
||||
const tagIds = await getOrCreateTagIds(options.tags || ['web-clip'], userId);
|
||||
const tagIds = await getOrCreateTagIds(tagsToApply, userId);
|
||||
|
||||
const note = await prisma.note.create({
|
||||
data: {
|
||||
|
||||
Reference in new issue
Block a user