Enhance admin interface, security, and feed management with improved UX and authentication

This commit is contained in:
Young Lee
2025-02-27 18:04:01 -08:00
parent 8839aac24b
commit 56a8263f33
19 changed files with 2022 additions and 523 deletions
+693 -484
View File
File diff suppressed because it is too large Load Diff
+10 -1
View File
@@ -40,7 +40,7 @@ export async function handle(c: Context): Promise<Response> {
contentType: payload.html ? 'HTML' : 'Text'
});
// Extract feed ID from email address (e.g., newsletter-xyz@domain.com -> xyz)
// Extract feed ID from email address (e.g., apple.mountain.42@domain.com -> apple.mountain.42)
const toAddress = payload.recipients?.[0] || '';
const feedId = EmailParser.extractFeedId(toAddress);
@@ -49,6 +49,15 @@ export async function handle(c: Context): Promise<Response> {
return new Response('Invalid email address format', { status: 400 });
}
// Check if the feed exists by looking up the feed configuration
const feedConfigKey = `feed:${feedId}:config`;
const feedConfig = await env.EMAIL_STORAGE.get(feedConfigKey, 'json');
if (!feedConfig) {
console.error(`Feed with ID ${feedId} does not exist or has been deleted`);
return new Response('Feed does not exist', { status: 404 });
}
// Parse the email using our simplified parser
const emailData = EmailParser.parseForwardEmailPayload(payload);
+3 -3
View File
@@ -33,8 +33,8 @@ export async function handle(c: Context): Promise<Response> {
const feedConfig = await emailStorage.get(feedConfigKey, 'json') as FeedConfig | null || {
title: `Newsletter Feed ${feedId}`,
description: 'Converted email newsletter',
site_url: `https://api.${env.DOMAIN}/rss/${feedId}`,
feed_url: `https://api.${env.DOMAIN}/rss/${feedId}`,
site_url: `https://${env.DOMAIN}/rss/${feedId}`,
feed_url: `https://${env.DOMAIN}/rss/${feedId}`,
language: 'en',
created_at: Date.now()
};
@@ -52,7 +52,7 @@ export async function handle(c: Context): Promise<Response> {
}
// Generate the RSS feed XML
const baseUrl = `https://api.${env.DOMAIN}`;
const baseUrl = `https://${env.DOMAIN}`;
const rssXml = generateRssFeed(feedConfig, emailsData, baseUrl);
// Return the RSS feed with appropriate content type