feat: Refine notice filtering and Docker setup

Implement granular notice filtering logic based on user roles and notice targeting.
Update Dockerfiles and .dockerignore for a cleaner build process.
This commit is contained in:
2025-12-09 14:15:43 +01:00
parent 891ea7a12c
commit 25eafb1c6e
5 changed files with 20 additions and 69 deletions

View File

@@ -30,12 +30,29 @@ export const FamilyList: React.FC = () => {
setSettings(appSettings);
if (condo && currentUser && appSettings.features.notices) {
const condoNotices = allNotices.filter(n => n.condoId === condo.id && n.active);
// Filter notices logic:
// 1. Must belong to current condo and be active
// 2. If Admin/PowerUser -> See everything
// 3. If standard User -> See Public notices (no target) OR Targeted notices containing their familyId
const isPrivileged = currentUser.role === 'admin' || currentUser.role === 'poweruser';
const condoNotices = allNotices.filter(n => {
if (n.condoId !== condo.id || !n.active) return false;
if (isPrivileged) return true;
// Check targeting
const hasTargets = n.targetFamilyIds && n.targetFamilyIds.length > 0;
if (!hasTargets) return true; // Public to all
return currentUser.familyId && n.targetFamilyIds?.includes(currentUser.familyId);
});
setNotices(condoNotices);
// Check which ones are read
const readStatuses = await Promise.all(condoNotices.map(n => CondoService.getNoticeReadStatus(n.id)));
const readIds = [];
const readIds: string[] = [];
readStatuses.forEach((reads, idx) => {
if (reads.find(r => r.userId === currentUser.id)) {
readIds.push(condoNotices[idx].id);
@@ -182,4 +199,4 @@ export const FamilyList: React.FC = () => {
</div>
</div>
);
};
};