mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-15 11:18:54 +02:00
Allow users to upload photos using shared Cloudinary configuration
Update routes to use a shared Cloudinary configuration for media uploads and adjust CloudinaryService to fetch any available config instead of user-specific config. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/vZocxw2
This commit is contained in:
1 parent
f98da13491
commit
3175ffee31
2 files changed
+12
-11
No files matched your search
+6
-6
@@ -467,7 +467,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const user = req.user as User;
|
||||
const userId = user.id;
|
||||
|
||||
// Check if Cloudinary is configured (use any admin config for all users)
|
||||
// Check if Cloudinary is configured (shared config used for all users)
|
||||
const cloudinaryConfig = await storage.getAnyCloudinaryConfig();
|
||||
|
||||
if (!cloudinaryConfig) {
|
||||
@@ -476,11 +476,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
});
|
||||
}
|
||||
|
||||
// Upload to Cloudinary using admin config
|
||||
// Upload to Cloudinary (service will use shared config internally)
|
||||
const uploadResult = await cloudinaryService.uploadMedia(
|
||||
req.file.buffer,
|
||||
req.file.originalname,
|
||||
cloudinaryConfig.userId,
|
||||
userId,
|
||||
req.file.mimetype
|
||||
);
|
||||
|
||||
@@ -667,7 +667,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
console.log("✅ Overlays applied, uploading to Cloudinary...");
|
||||
|
||||
// Check if Cloudinary is configured (use any admin config for all users)
|
||||
// Check if Cloudinary is configured (shared config used for all users)
|
||||
const cloudinaryConfig = await storage.getAnyCloudinaryConfig();
|
||||
if (!cloudinaryConfig) {
|
||||
return res.status(400).json({
|
||||
@@ -675,11 +675,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
});
|
||||
}
|
||||
|
||||
// Upload to Cloudinary using admin config
|
||||
// Upload to Cloudinary (service will use shared config internally)
|
||||
const uploadResult = await cloudinaryService.uploadMedia(
|
||||
outputBuffer,
|
||||
`edited_${Date.now()}.jpg`,
|
||||
cloudinaryConfig.userId,
|
||||
userId,
|
||||
'image/jpeg'
|
||||
);
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ class CloudinaryService {
|
||||
instagramFeedUrl: string | null;
|
||||
instagramStoryUrl: string | null;
|
||||
}> {
|
||||
// Get user's Cloudinary config
|
||||
const config = await storage.getCloudinaryConfig(userId);
|
||||
// Get any available Cloudinary config (shared across all users)
|
||||
const config = await storage.getAnyCloudinaryConfig();
|
||||
|
||||
if (!config) {
|
||||
throw new Error('Cloudinary configuration not found. Please configure Cloudinary in Settings.');
|
||||
throw new Error('Cloudinary configuration not found. Please ask an administrator to configure Cloudinary in Settings first.');
|
||||
}
|
||||
|
||||
// Configure Cloudinary with user's credentials
|
||||
@@ -81,10 +81,11 @@ class CloudinaryService {
|
||||
}
|
||||
|
||||
async deleteMedia(publicId: string, userId: string, mediaType: 'image' | 'video'): Promise<void> {
|
||||
const config = await storage.getCloudinaryConfig(userId);
|
||||
// Get any available Cloudinary config (shared across all users)
|
||||
const config = await storage.getAnyCloudinaryConfig();
|
||||
|
||||
if (!config) {
|
||||
throw new Error('Cloudinary configuration not found');
|
||||
throw new Error('Cloudinary configuration not found. Please ask an administrator to configure Cloudinary in Settings first.');
|
||||
}
|
||||
|
||||
cloudinary.config({
|
||||
|
||||
Reference in new issue
Block a user