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