All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m25s
- Add DeepSeek, OpenRouter, Mistral, Z.AI, LM Studio as AI providers with editable model names via Combobox in admin settings - Fix OpenRouter broken by normalizeProvider bug in config.ts - Convert agent-created notes from Markdown to HTML (TipTap rich text) - Add Notification model + in-app notifications for agent results - Agent notification click opens the created note directly - Add note count display on notebook and inbox headers - Fix checklist toggle in card view (persist state via localCheckItems) - Add checklist creation option in tabs/list view (dropdown on + button) - Fix image description ENOENT error with HTTP fallback - Improve UI contrast across all themes (input, border, checkbox visibility) - Add font family setting (Inter vs System Default) in Appearance settings - Fix CSS font-sans variable conflict (removed dead Geist references) - Update README with new features and 8 providers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
'use server'
|
|
|
|
import prisma from '@/lib/prisma'
|
|
import { auth } from '@/auth'
|
|
import { sendEmail } from '@/lib/mail'
|
|
|
|
async function checkAdmin() {
|
|
const session = await auth()
|
|
if (!session?.user?.id || (session.user as any).role !== 'ADMIN') {
|
|
throw new Error('Unauthorized: Admin access required')
|
|
}
|
|
return session
|
|
}
|
|
|
|
export async function testEmail(provider: 'resend' | 'smtp' = 'smtp') {
|
|
const session = await checkAdmin()
|
|
const email = session.user?.email
|
|
|
|
if (!email) throw new Error("No admin email found")
|
|
|
|
const subject = provider === 'resend'
|
|
? "Memento Resend Test"
|
|
: "Memento SMTP Test"
|
|
|
|
const html = provider === 'resend'
|
|
? "<p>This is a test email from your Memento instance. <strong>Resend is working!</strong></p>"
|
|
: "<p>This is a test email from your Memento instance. <strong>SMTP is working!</strong></p>"
|
|
|
|
const result = await sendEmail({
|
|
to: email,
|
|
subject,
|
|
html,
|
|
}, provider)
|
|
|
|
return result
|
|
}
|
|
|
|
export async function getSystemConfig() {
|
|
await checkAdmin()
|
|
// Reuse the cached version from lib/config
|
|
const { getSystemConfig: getCachedConfig } = await import('@/lib/config')
|
|
return getCachedConfig()
|
|
}
|
|
|
|
export async function updateSystemConfig(data: Record<string, string>) {
|
|
await checkAdmin()
|
|
|
|
try {
|
|
// Filter out empty values but keep 'false' as valid
|
|
const filteredData = Object.fromEntries(
|
|
Object.entries(data).filter(([key, value]) => value !== '' && value !== null && value !== undefined)
|
|
)
|
|
|
|
const operations = Object.entries(filteredData).map(([key, value]) =>
|
|
prisma.systemConfig.upsert({
|
|
where: { key },
|
|
update: { value },
|
|
create: { key, value }
|
|
})
|
|
)
|
|
|
|
await prisma.$transaction(operations)
|
|
|
|
return { success: true }
|
|
} catch (error) {
|
|
console.error('Failed to update settings:', error)
|
|
return { error: 'Failed to update settings' }
|
|
}
|
|
}
|