aktueller stand

This commit is contained in:
2026-01-05 19:58:07 +01:00
parent 677eac2632
commit b81c2042e9
2 changed files with 98 additions and 22 deletions

View File

@@ -1044,6 +1044,7 @@ async function markPostChecked(postId, profileNumber, options = {}) {
try {
const ignoreOrder = options && options.ignoreOrder === true;
const returnError = options && options.returnError === true;
const allowOutOfOrderOnConflict = options && options.allowOutOfOrderOnConflict !== false;
console.log('[FB Tracker] Marking post as checked:', postId, 'Profile:', profileNumber);
const response = await backendFetch(`${API_URL}/posts/${postId}/check`, {
method: 'POST',
@@ -1066,6 +1067,14 @@ async function markPostChecked(postId, profileNumber, options = {}) {
const payload = await response.json().catch(() => ({}));
const message = payload && payload.error ? payload.error : 'Beitrag kann aktuell nicht bestätigt werden.';
console.log('[FB Tracker] Post check blocked:', message);
if (!ignoreOrder && allowOutOfOrderOnConflict && Array.isArray(payload.missing_profiles) && payload.missing_profiles.length) {
return markPostChecked(postId, profileNumber, {
...options,
ignoreOrder: true,
returnError: true,
allowOutOfOrderOnConflict: false
});
}
return returnError ? { error: message, status: response.status } : null;
}
@@ -2224,6 +2233,7 @@ function extractDeadlineFromPostText(postElement) {
}
const fullText = textNodes.join(' ');
const normalizedText = fullText.replace(/(\d)\s*([.:])\s*(\d)/g, '$1$2$3');
const today = new Date();
today.setHours(0, 0, 0, 0);
@@ -2278,12 +2288,12 @@ function extractDeadlineFromPostText(postElement) {
const hasInclusiveKeywordNear = (text, index) => {
const windowStart = Math.max(0, index - 40);
const windowText = text.slice(windowStart, index).toLowerCase();
return /\b(einschlie(?:ß|ss)lich|inklusive|inkl\.)\b/.test(windowText);
return /\b(einschlie(?:ß|ss)lich|einschl\.?|inklusive|inkl\.)\b/.test(windowText);
};
const foundDates = [];
const rangePattern = /\b(\d{1,2})\.(\d{1,2})\.(\d{2,4})\s*(?:-||—|bis)\s*(\d{1,2})\.(\d{1,2})\.(\d{2,4})\b/i;
const rangeMatch = rangePattern.exec(fullText);
const rangeMatch = rangePattern.exec(normalizedText);
if (rangeMatch) {
const endDay = parseInt(rangeMatch[4], 10);
const endMonth = parseInt(rangeMatch[5], 10);
@@ -2301,7 +2311,7 @@ function extractDeadlineFromPostText(postElement) {
for (const pattern of patterns) {
let match;
while ((match = pattern.exec(fullText)) !== null) {
while ((match = pattern.exec(normalizedText)) !== null) {
const day = parseInt(match[1], 10);
const month = parseInt(match[2], 10);
let year = match[3] ? parseInt(match[3], 10) : today.getFullYear();
@@ -2318,15 +2328,15 @@ function extractDeadlineFromPostText(postElement) {
// Check if date is valid (e.g., not 31.02.)
if (date.getMonth() === month - 1 && date.getDate() === day) {
const timeInfo = extractTimeAfterIndex(fullText, pattern.lastIndex);
const timeInfo = extractTimeAfterIndex(normalizedText, pattern.lastIndex);
const hasTime = Boolean(timeInfo);
if (timeInfo) {
date.setHours(timeInfo.hour, timeInfo.minute, 0, 0);
} else if (hasInclusiveKeywordNear(fullText, matchIndex)) {
} else if (hasInclusiveKeywordNear(normalizedText, matchIndex)) {
date.setHours(23, 59, 0, 0);
}
const hasInclusiveTime = hasInclusiveKeywordNear(fullText, matchIndex);
const hasInclusiveTime = hasInclusiveKeywordNear(normalizedText, matchIndex);
const recordHasTime = hasTime || hasInclusiveTime;
if (hasInclusiveTime && !hasTime) {
date.setHours(23, 59, 0, 0);
@@ -2344,7 +2354,7 @@ function extractDeadlineFromPostText(postElement) {
// Pattern for "12. Oktober" or "12 Oktober"
const monthPattern = /\b(\d{1,2})\.?\s*(januar|jan|februar|feb|märz|mär|maerz|april|apr|mai|juni|jun|juli|jul|august|aug|september|sep|sept|oktober|okt|november|nov|dezember|dez)\s*(\d{2,4})?\b/gi;
let monthMatch;
while ((monthMatch = monthPattern.exec(fullText)) !== null) {
while ((monthMatch = monthPattern.exec(normalizedText)) !== null) {
const day = parseInt(monthMatch[1], 10);
const monthStr = monthMatch[2].toLowerCase();
const month = monthNames[monthStr];
@@ -2362,15 +2372,15 @@ function extractDeadlineFromPostText(postElement) {
// Check if date is valid
if (date.getMonth() === month - 1 && date.getDate() === day) {
const timeInfo = extractTimeAfterIndex(fullText, monthPattern.lastIndex);
const timeInfo = extractTimeAfterIndex(normalizedText, monthPattern.lastIndex);
const hasTime = Boolean(timeInfo);
if (timeInfo) {
date.setHours(timeInfo.hour, timeInfo.minute, 0, 0);
} else if (hasInclusiveKeywordNear(fullText, matchIndex)) {
} else if (hasInclusiveKeywordNear(normalizedText, matchIndex)) {
date.setHours(23, 59, 0, 0);
}
const hasInclusiveTime = hasInclusiveKeywordNear(fullText, matchIndex);
const hasInclusiveTime = hasInclusiveKeywordNear(normalizedText, matchIndex);
const recordHasTime = hasTime || hasInclusiveTime;
if (hasInclusiveTime && !hasTime) {
date.setHours(23, 59, 0, 0);