mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-22 22:48:09 +02:00
feat: Replace external storage with local file storage + auto cleanup
Media is now stored directly on the server disk (no external service). Files are served via Express static middleware at /uploads/*. Cleanup rules: - Videos deleted immediately after successful publish to Facebook/Instagram - Videos older than 7 days purged daily by cron job - Images older than 30 days purged daily by cron job Changes: - server/services/minio.ts: replaced S3 client with local fs read/write - server/index.ts: added static serving for /uploads/media, /logos, /stories - server/services/media-purge.ts: new rules (images 30d, videos 7d) - server/services/scheduler.ts: delete local videos after successful publish - docker-compose.yml: add media_uploads, logos_uploads, stories_uploads volumes - settings UI: removed credentials card, shows local storage info - package.json: removed googleapis (unneeded) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba94e7cc7d
commit
7733acbc22
9 files changed
+145
-378
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import cron, { ScheduledTask } from "node-cron";
|
||||
import { storage } from "../storage";
|
||||
import { facebookService } from "./facebook";
|
||||
import { minioService as storageService } from "./minio";
|
||||
|
||||
export class SchedulerService {
|
||||
private task: ScheduledTask | null = null;
|
||||
@@ -124,6 +125,18 @@ export class SchedulerService {
|
||||
status: "published",
|
||||
});
|
||||
|
||||
// Delete local video files immediately after successful publishing
|
||||
for (const mediaItem of mediaList) {
|
||||
if (mediaItem.type === 'video' && mediaItem.cloudinaryPublicId) {
|
||||
try {
|
||||
await storageService.deleteMedia(mediaItem.cloudinaryPublicId, mediaItem.userId, 'video');
|
||||
console.log(`[Scheduler] Deleted local video file for media ${mediaItem.id}`);
|
||||
} catch (err) {
|
||||
console.warn(`[Scheduler] Failed to delete local video file for media ${mediaItem.id}:`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Successfully published post ${post.id} with external ID: ${externalPostId}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user