mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 19:44:12 +00:00
fix: resolve TypeScript and lint errors in video feature
- Fix slug-validation.ts: Use proper Where type from Payload - Fix processFeaturedVideo.ts: Remove TypeWithID constraint, use type casting - Fix retention-worker.ts: Remove unused import cleanupExpiredConsentLogs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
913897c87c
commit
d449da6915
3 changed files with 23 additions and 19 deletions
|
|
@ -25,7 +25,7 @@ interface FeaturedVideoData {
|
|||
thumbnailUrl?: string
|
||||
}
|
||||
|
||||
interface PostData {
|
||||
interface PostDataInput {
|
||||
featuredVideo?: FeaturedVideoData
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
|
@ -37,16 +37,17 @@ interface PostData {
|
|||
* - Generiert normalisierte Embed-URL mit Privacy-Mode (youtube-nocookie)
|
||||
* - Speichert Thumbnail-URL für Fallback
|
||||
*/
|
||||
export const processFeaturedVideo: CollectionBeforeChangeHook<PostData> = async ({
|
||||
export const processFeaturedVideo: CollectionBeforeChangeHook = async ({
|
||||
data,
|
||||
operation,
|
||||
}) => {
|
||||
const postData = data as PostDataInput | undefined
|
||||
|
||||
// Nur wenn featuredVideo existiert und aktiviert ist
|
||||
if (!data?.featuredVideo?.enabled) {
|
||||
if (!postData?.featuredVideo?.enabled) {
|
||||
return data
|
||||
}
|
||||
|
||||
const featuredVideo = data.featuredVideo
|
||||
const featuredVideo = postData.featuredVideo
|
||||
|
||||
// Nur für embed source verarbeiten
|
||||
if (featuredVideo.source !== 'embed' || !featuredVideo.embedUrl) {
|
||||
|
|
@ -82,7 +83,7 @@ export const processFeaturedVideo: CollectionBeforeChangeHook<PostData> = async
|
|||
}
|
||||
|
||||
return {
|
||||
...data,
|
||||
...postData,
|
||||
featuredVideo,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import { QUEUE_NAMES, getQueueRedisConnection } from '../queue-service'
|
|||
import type { RetentionJobData, RetentionJobResult } from '../jobs/retention-job'
|
||||
import {
|
||||
cleanupCollection,
|
||||
cleanupExpiredConsentLogs,
|
||||
cleanupOrphanedMedia,
|
||||
runFullRetention,
|
||||
} from '../../retention/cleanup-service'
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
* Stellt sicher, dass Slugs innerhalb eines Tenants eindeutig sind.
|
||||
*/
|
||||
|
||||
import type { Payload } from 'payload'
|
||||
import type { Payload, Where } from 'payload'
|
||||
import type { Config } from '@/payload-types'
|
||||
|
||||
type CollectionSlug = keyof Config['collections']
|
||||
type LocaleType = 'de' | 'en' | 'all' | undefined
|
||||
|
||||
export interface SlugValidationOptions {
|
||||
/** Collection slug */
|
||||
|
|
@ -51,27 +52,30 @@ export async function validateUniqueSlug(
|
|||
}
|
||||
|
||||
// Build where clause
|
||||
const where: Record<string, unknown> = {
|
||||
[slugField]: { equals: slug },
|
||||
}
|
||||
const conditions: Where[] = [{ [slugField]: { equals: slug } }]
|
||||
|
||||
// Add tenant filter if tenant is set
|
||||
if (tenantId) {
|
||||
where[tenantField] = { equals: tenantId }
|
||||
conditions.push({ [tenantField]: { equals: tenantId } })
|
||||
}
|
||||
|
||||
// Exclude current document when updating
|
||||
if (existingId) {
|
||||
where.id = { not_equals: existingId }
|
||||
conditions.push({ id: { not_equals: existingId } })
|
||||
}
|
||||
|
||||
const where: Where = conditions.length > 1 ? { and: conditions } : conditions[0]
|
||||
|
||||
// Determine locale for query
|
||||
const queryLocale: LocaleType = perLocale && locale ? (locale as LocaleType) : undefined
|
||||
|
||||
// Check for existing documents with same slug
|
||||
const existing = await payload.find({
|
||||
collection,
|
||||
where,
|
||||
limit: 1,
|
||||
depth: 0,
|
||||
locale: perLocale ? locale : undefined,
|
||||
locale: queryLocale,
|
||||
})
|
||||
|
||||
if (existing.totalDocs > 0) {
|
||||
|
|
@ -125,18 +129,18 @@ export async function generateUniqueSlug(
|
|||
let isUnique = false
|
||||
|
||||
while (!isUnique && counter < 100) {
|
||||
const where: Record<string, unknown> = {
|
||||
[slugField]: { equals: slug },
|
||||
}
|
||||
const conditions: Where[] = [{ [slugField]: { equals: slug } }]
|
||||
|
||||
if (tenantId) {
|
||||
where[tenantField] = { equals: tenantId }
|
||||
conditions.push({ [tenantField]: { equals: tenantId } })
|
||||
}
|
||||
|
||||
if (existingId) {
|
||||
where.id = { not_equals: existingId }
|
||||
conditions.push({ id: { not_equals: existingId } })
|
||||
}
|
||||
|
||||
const where: Where = conditions.length > 1 ? { and: conditions } : conditions[0]
|
||||
|
||||
const existing = await payload.find({
|
||||
collection,
|
||||
where,
|
||||
|
|
|
|||
Loading…
Reference in a new issue