Autosave: 20260215-170412

This commit is contained in:
Flatlogic Bot 2026-02-15 17:04:12 +00:00
parent 001690b707
commit 1440c83ccf
4 changed files with 23 additions and 6 deletions

View File

@ -1486,11 +1486,21 @@ document.addEventListener('DOMContentLoaded', () => {
}
if (msg.is_pinned) div.classList.add('pinned');
const ytRegex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
const ytRegex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
const dmRegex = /(?:https?:\/\/)?(?:www\.)?(?:dailymotion\.com\/video\/|dai\.ly\/)([a-zA-Z0-9]+)/;
const vimeoRegex = /(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/;
const ytMatch = msg.content.match(ytRegex);
let ytHtml = '';
const dmMatch = msg.content.match(dmRegex);
const vimeoMatch = msg.content.match(vimeoRegex);
let videoHtml = '';
if (ytMatch && ytMatch[1]) {
ytHtml = `<div class="youtube-embed mt-2"><iframe width="100%" height="315" src="https://www.youtube.com/embed/${ytMatch[1]}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="border-radius: 8px; max-width: 560px;"></iframe></div>`;
videoHtml = `<div class="video-embed mt-2"><iframe width="100%" height="315" src="https://www.youtube.com/embed/${ytMatch[1]}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="border-radius: 8px; max-width: 560px;"></iframe></div>`;
} else if (dmMatch && dmMatch[1]) {
videoHtml = `<div class="video-embed mt-2"><iframe width="100%" height="315" src="https://www.dailymotion.com/embed/video/${dmMatch[1]}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="border-radius: 8px; max-width: 560px;"></iframe></div>`;
} else if (vimeoMatch && vimeoMatch[1]) {
videoHtml = `<div class="video-embed mt-2"><iframe width="100%" height="315" src="https://player.vimeo.com/video/${vimeoMatch[1]}" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="border-radius: 8px; max-width: 560px;"></iframe></div>`;
}
const authorStyle = msg.role_color ? `color: ${msg.role_color};` : '';
@ -1506,8 +1516,8 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="message-text">
${escapeHTML(msg.content).replace(/\n/g, '<br>').replace(mentionRegex, `<span class="mention">@${window.currentUsername}</span>`)}
${attachmentHtml}
${ytHtml}
${ytHtml ? '' : embedHtml}
${videoHtml}
${videoHtml ? '' : embedHtml}
</div>
<div class="message-reactions mt-1" data-message-id="${msg.id}">
<span class="add-reaction-btn" title="Add Reaction">+</span>

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -4,9 +4,15 @@ require_once __DIR__ . '/../ai/LocalAIApi.php';
function moderateContent($content) {
if (empty(trim($content))) return ['is_safe' => true];
// Bypass moderation for video platforms as they are handled by their own safety measures
// and often trigger false positives in AI moderation due to "lack of context".
if (preg_match('/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be|dailymotion\.com|dai\.ly|vimeo\.com)\//i', $content)) {
return ['is_safe' => true];
}
$resp = LocalAIApi::createResponse([
'input' => [
['role' => 'system', 'content' => 'You are a content moderator. Analyze the message and return a JSON object with "is_safe" (boolean) and "reason" (string, optional). Safe means no hate speech, extreme violence, or explicit sexual content.'],
['role' => 'system', 'content' => 'You are a content moderator. Analyze the message and return a JSON object with "is_safe" (boolean) and "reason" (string, optional). Safe means no hate speech, extreme violence, or explicit sexual content. Do not flag URLs as unsafe simply because you cannot see the content behind them.'],
['role' => 'user', 'content' => $content],
],
]);

View File

@ -11,6 +11,7 @@ function fetchOpenGraphData($url) {
curl_close($ch);
if (!$html || $info['http_code'] !== 200) return null;
if (!class_exists('DOMDocument')) return null;
$doc = new DOMDocument();
@$doc->loadHTML($html);