Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion directus-cms/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,30 @@ ALGOLIA_INDEX="programmierbar_website_dev"
####################################################################################################
## Vercel

VERCEL_DEPLOY_WEBHOOK_URL=""
VERCEL_DEPLOY_WEBHOOK_URL=""

####################################################################################################
## Gemini (Content Generation)

GEMINI_API_KEY=""

####################################################################################################
## Social Media Publishing

# Bluesky (AT Protocol)
BLUESKY_HANDLE=""
BLUESKY_APP_PASSWORD=""

# Mastodon
MASTODON_INSTANCE_URL=""
MASTODON_ACCESS_TOKEN=""

# LinkedIn (OAuth 2.0)
LINKEDIN_CLIENT_ID=""
LINKEDIN_CLIENT_SECRET=""
LINKEDIN_ACCESS_TOKEN=""
LINKEDIN_COMPANY_ID=""

# Instagram (via Facebook Graph API)
INSTAGRAM_BUSINESS_ACCOUNT_ID=""
FACEBOOK_ACCESS_TOKEN=""
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@
"name": "algolia-index",
"source": "src/algolia-index/index.ts"
},
{
"type": "hook",
"name": "member-matching",
"source": "src/member-matching/index.ts"
},
{
"type": "hook",
"name": "content-generation",
"source": "src/content-generation/index.ts"
},
{
"type": "hook",
"name": "content-approval",
"source": "src/content-approval/index.ts"
},
{
"type": "hook",
"name": "social-media-publish",
"source": "src/social-media-publish/index.ts"
},
{
"type": "endpoint",
"name": "conference",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { defineHook } from '@directus/extensions-sdk'

const HOOK_NAME = 'content-approval'

export default defineHook(({ action }, hookContext) => {
const logger = hookContext.logger
const ItemsService = hookContext.services.ItemsService
const getSchema = hookContext.getSchema

// Listen for updates to podcast_generated_content
action('podcast_generated_content.items.update', async function (metadata, eventContext) {
const { payload, keys } = metadata

// Only proceed if status is being set to 'approved'
if (payload.status !== 'approved') {
return
}

try {
const schema = await getSchema()

const generatedContentService = new ItemsService('podcast_generated_content', {
schema,
accountability: eventContext.accountability,
})

const podcastsService = new ItemsService('podcasts', {
schema,
accountability: eventContext.accountability,
})

// Process each approved content item
for (const contentId of keys) {
const content = await generatedContentService.readOne(contentId, {
fields: ['id', 'podcast_id', 'content_type', 'generated_text'],
})

if (!content || !content.podcast_id) {
continue
}

// If this is shownotes, copy to podcast description
if (content.content_type === 'shownotes') {
if (content.generated_text) {
logger.info(
`${HOOK_NAME}: Copying approved shownotes to podcast ${content.podcast_id} description`
)

await podcastsService.updateOne(content.podcast_id, {
description: content.generated_text,
})
}
}

// Check if all content for this podcast is approved
const allContent = await generatedContentService.readByQuery({
filter: {
podcast_id: { _eq: content.podcast_id },
},
fields: ['id', 'status'],
})

const allApproved =
allContent.length > 0 && allContent.every((c: any) => c.status === 'approved')

if (allApproved) {
logger.info(
`${HOOK_NAME}: All content approved for podcast ${content.podcast_id}, updating status to 'approved'`
)

await podcastsService.updateOne(content.podcast_id, {
publishing_status: 'approved',
})
}
}
} catch (err: any) {
logger.error(`${HOOK_NAME}: Error processing content approval: ${err?.message || err}`)
}
})

logger.info(`${HOOK_NAME} hook registered`)
})
Loading