Allow administrators to edit media outlet descriptions
Adds functionality for admins to update media outlet descriptions via an API endpoint and UI modal, including an option to use a predefined alternative description. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/UXwUwik
This commit is contained in:
@ -44,6 +44,30 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
app.patch('/api/media-outlets/:slug', isAuthenticated, async (req: any, res) => {
|
||||
try {
|
||||
const user = req.user;
|
||||
|
||||
if (!user || (user.role !== 'admin' && user.role !== 'superadmin')) {
|
||||
return res.status(403).json({ message: "Insufficient permissions" });
|
||||
}
|
||||
|
||||
const { description } = req.body;
|
||||
const outlet = await storage.getMediaOutletBySlug(req.params.slug);
|
||||
|
||||
if (!outlet) {
|
||||
return res.status(404).json({ message: "Media outlet not found" });
|
||||
}
|
||||
|
||||
await storage.updateMediaOutlet(outlet.id, { description });
|
||||
const updated = await storage.getMediaOutletBySlug(req.params.slug);
|
||||
res.json(updated);
|
||||
} catch (error) {
|
||||
console.error("Error updating media outlet:", error);
|
||||
res.status(500).json({ message: "Failed to update media outlet" });
|
||||
}
|
||||
});
|
||||
|
||||
// Article routes
|
||||
app.get('/api/media-outlets/:outletId/articles', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user