feat(notifications): Refactor notification system and consolidate interaction handlers

- Remove dedicated bot owner notification utility in favor of unified notification system
- Update all interaction endpoints (follow, like, mention, repost) to use consolidated notification flow
- Refactor notification route to handle all interaction types through single endpoint
- Update posts endpoints to trigger notifications through unified system
- Add database migration snapshot for notification schema changes
- Simplify notification logic by removing redundant bot owner notification module
- Improve notification consistency across all user interactions and post operations
This commit is contained in:
Christomatt
2026-01-26 12:45:35 +01:00
parent 17c68a99bf
commit 12f515b7fb
14 changed files with 3935 additions and 263 deletions
+32 -1
View File
@@ -12,6 +12,7 @@ export function Sidebar() {
const { user, isAdmin } = useAuth();
const pathname = usePathname();
const [customLogoUrl, setCustomLogoUrl] = useState<string | null | undefined>(undefined);
const [unreadCount, setUnreadCount] = useState(0);
useEffect(() => {
fetch('/api/node')
@@ -24,6 +25,25 @@ export function Sidebar() {
});
}, []);
// Fetch unread notification count
useEffect(() => {
if (!user) return;
const fetchUnread = () => {
fetch('/api/notifications?unread=true&limit=50')
.then(res => res.json())
.then(data => {
setUnreadCount(data.notifications?.length || 0);
})
.catch(() => {});
};
fetchUnread();
// Poll every 30 seconds
const interval = setInterval(fetchUnread, 30000);
return () => clearInterval(interval);
}, [user]);
// Home is exact match
const isHome = pathname === '/';
@@ -46,9 +66,20 @@ export function Sidebar() {
<span>Explore</span>
</Link>
{user && (
<Link href="/notifications" className={`nav-item ${pathname?.startsWith('/notifications') ? 'active' : ''}`}>
<Link href="/notifications" className={`nav-item ${pathname?.startsWith('/notifications') ? 'active' : ''}`} style={{ position: 'relative' }}>
<BellIcon />
<span>Notifications</span>
{unreadCount > 0 && (
<span style={{
position: 'absolute',
top: '8px',
left: '24px',
width: '8px',
height: '8px',
background: 'var(--error)',
borderRadius: '50%',
}} />
)}
</Link>
)}
{user && (