mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Show all scheduled posts for accessible pages to users
Update scheduled post retrieval logic to fetch posts from all users and then filter by accessible pages, resolving an issue where users could not see posts created by the admin. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/1VOBLTw
This commit is contained in:
1 parent
f305d62091
commit
f21e7e5f18
1 file changed
+9
-3
+9
-3
@@ -772,12 +772,18 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const allPostsArrays = await Promise.all(allPostsPromises);
|
||||
scheduledPosts = allPostsArrays.flat();
|
||||
} else {
|
||||
// User voit uniquement les posts des pages qui lui sont attribuées
|
||||
// User voit tous les posts programmés sur les pages qui lui sont attribuées (peu importe qui les a créés)
|
||||
const accessiblePages = await storage.getUserAccessiblePages(userId);
|
||||
const accessiblePageIds = accessiblePages.map(p => p.id);
|
||||
|
||||
const userScheduledPosts = await storage.getScheduledPosts(userId, start, end);
|
||||
scheduledPosts = userScheduledPosts.filter(sp => accessiblePageIds.includes(sp.pageId));
|
||||
// Récupérer tous les posts programmés de tous les utilisateurs
|
||||
const allUsers = await storage.getAllUsers();
|
||||
const allPostsPromises = allUsers.map(u => storage.getScheduledPosts(u.id, start, end));
|
||||
const allPostsArrays = await Promise.all(allPostsPromises);
|
||||
const allScheduledPosts = allPostsArrays.flat();
|
||||
|
||||
// Filtrer uniquement les posts des pages accessibles
|
||||
scheduledPosts = allScheduledPosts.filter(sp => accessiblePageIds.includes(sp.pageId));
|
||||
}
|
||||
|
||||
res.json(scheduledPosts);
|
||||
|
||||
Reference in new issue
Block a user