scroller filename as metadata
This commit is contained in:
@@ -209,6 +209,12 @@
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
function decodeHtmlEntities(str) {
|
||||
if (!str) return '';
|
||||
const txt = document.createElement('textarea');
|
||||
txt.innerHTML = String(str);
|
||||
return txt.value;
|
||||
}
|
||||
function timeAgo(iso) {
|
||||
const s = Math.floor((Date.now() - new Date(iso)) / 1000);
|
||||
const i = window.f0ckI18n || {};
|
||||
@@ -1690,7 +1696,8 @@
|
||||
is_audio: false,
|
||||
comment_count: p.replies || 0,
|
||||
rating_label: isWsg ? 'SFW' : (isGif ? 'NSFW' : 'External'),
|
||||
rating_class: isWsg ? 'sfw' : (isGif ? 'nsfw' : 'untagged')
|
||||
rating_class: isWsg ? 'sfw' : (isGif ? 'nsfw' : 'untagged'),
|
||||
original_filename: p.filename ? `${decodeHtmlEntities(p.filename)}${ext}` : null
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
@@ -1855,7 +1862,8 @@
|
||||
url: item.external_media_url || item.dest,
|
||||
rating: rating,
|
||||
tags: '4chan',
|
||||
comment: `Rehosted from 4chan thread: ${applied.externalUrl || 'unknown'}`
|
||||
comment: `Rehosted from 4chan thread: ${applied.externalUrl || 'unknown'}`,
|
||||
...(item.original_filename ? { original_filename: item.original_filename } : {})
|
||||
})
|
||||
});
|
||||
const data = await resp.json();
|
||||
|
||||
@@ -319,7 +319,7 @@ export default (router) => {
|
||||
// POST /api/v2/scroller/rehost
|
||||
// Downloads an external item and adds it to the platform
|
||||
router.post(/^\/api\/v2\/scroller\/rehost\/?$/, lib.loggedin, async (req, res) => {
|
||||
const { url, rating: initialRating, tags: tagsRaw, comment, is_oc } = req.post || {};
|
||||
const { url, rating: initialRating, tags: tagsRaw, comment, is_oc, original_filename } = req.post || {};
|
||||
|
||||
if (!url) return res.reply({ code: 400, body: JSON.stringify({ success: false, msg: 'URL is required' }) });
|
||||
|
||||
@@ -436,8 +436,9 @@ export default (router) => {
|
||||
usernetwork: 'web',
|
||||
stamp: ~~(Date.now() / 1000),
|
||||
active: !isApprovalRequired,
|
||||
is_oc: !!is_oc
|
||||
}, 'src', 'dest', 'mime', 'size', 'checksum', 'phash', 'username', 'userchannel', 'usernetwork', 'stamp', 'active', 'is_oc')}
|
||||
is_oc: !!is_oc,
|
||||
original_filename: original_filename || null
|
||||
}, 'src', 'dest', 'mime', 'size', 'checksum', 'phash', 'username', 'userchannel', 'usernetwork', 'stamp', 'active', 'is_oc', 'original_filename')}
|
||||
RETURNING id
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user