feat(sprint7): Phase 4 — Integration (SMTP, tier enforcement, WebSocket)

Phase 4 implementation:
- 4.1 IONOS SMTP email configuration (production + docker profiles)
- 4.2 Portal navigation update (info board, events, forum links)
- 4.3 Tier enforcement: PlanTierService (forum=Pro+, info board limits)
- 4.4 WebSocket real-time updates (WebSocketEventPublisher)
- 4.5 EmailService: notification, event reminder, info board templates + rate limiting
- 4.6 Enterprise custom FROM: CustomMailDomain entity, DNS verification, controller

New files:
- PlanTierService: tier checks for forum/info board/enterprise features
- NotificationDispatchService: EMAIL channel dispatch via preferences
- WebSocketEventPublisher: STOMP topic push for forum/info board/events
- CustomMailDomainService: DNS TXT record verification for custom FROM
- MailSettingsController: Enterprise custom domain API endpoints
- CustomMailDomain entity + repository
- V16 migration: email dispatch index
- V17 migration: custom_mail_domains table
- Frontend: use-forum-subscription + use-info-board-subscription hooks
- Portal navbar: added info board, events, forum navigation items
- i18n: added portal nav translations (de + en)

Also fixed pre-existing Phase 2.5/3 compilation issues:
- Member entity: added userId field
- AuditService: added convenience overloads (logEvent, 4-param log)
- AuditEventType: added INFO_BOARD_POST_UPDATED, INFO_BOARD_POST_DELETED
- QuotaViolationCode: added TIER_UPGRADE_REQUIRED
- StaffPermissionChecker: added requirePermission(UserDetails, ...)
- TenantContext: added getCurrentTenantId() alias
- MemberRepository: added findByUserId, findByClubId, findAllByClubId
- EmailServiceTest: updated for new constructor signature
This commit is contained in:
Patrick Plate
2026-06-13 20:51:10 +02:00
parent a539ed9eb2
commit aabde17532
26 changed files with 1174 additions and 82 deletions
+3
View File
@@ -243,6 +243,9 @@
"networkError": "Verbindungsfehler. Bitte versuche es erneut.",
"welcome": "Willkommen zurück, {name}!",
"dashboard": "Übersicht",
"infoBoard": "Ankündigungen",
"events": "Termine",
"forum": "Forum",
"quota": "Mein Kontingent",
"history": "Ausgabe-Verlauf",
"profile": "Profil",
+3
View File
@@ -243,6 +243,9 @@
"networkError": "Connection error. Please try again.",
"welcome": "Welcome back, {name}!",
"dashboard": "Overview",
"infoBoard": "Announcements",
"events": "Events",
"forum": "Forum",
"quota": "My Quota",
"history": "Distribution History",
"profile": "Profile",
@@ -3,7 +3,7 @@
import Link from "next/link"
import { usePathname } from "next/navigation"
import { useTranslations } from "next-intl"
import { Cannabis, History, LayoutDashboard, LogOut, User } from "lucide-react"
import { Calendar, Cannabis, History, LayoutDashboard, LogOut, Megaphone, MessageSquare, User } from "lucide-react"
import { mockPortalUser } from "@/data/mock/portal"
@@ -13,6 +13,9 @@ import { ModeDropdown } from "@/components/layout/mode-dropdown"
const navItems = [
{ href: "/portal/dashboard", icon: LayoutDashboard, labelKey: "dashboard" },
{ href: "/portal/info-board", icon: Megaphone, labelKey: "infoBoard" },
{ href: "/portal/events", icon: Calendar, labelKey: "events" },
{ href: "/portal/forum", icon: MessageSquare, labelKey: "forum" },
{ href: "/portal/history", icon: History, labelKey: "history" },
{ href: "/portal/profile", icon: User, labelKey: "profile" },
] as const
@@ -0,0 +1,84 @@
"use client"
import { useEffect, useCallback, useRef } from "react"
/**
* Hook to subscribe to forum WebSocket events for a specific club.
* Listens for new topics and replies in real-time.
*/
export function useForumSubscription(
clubId: string | undefined,
topicId?: string,
onNewTopic?: (data: ForumTopicEvent) => void,
onNewReply?: (data: ForumReplyEvent) => void
) {
const stompClientRef = useRef<any>(null)
useEffect(() => {
if (!clubId) return
// Dynamic import of SockJS client
const connectWebSocket = async () => {
try {
const SockJS = (await import("sockjs-client")).default
const { Client } = await import("@stomp/stompjs")
const client = new Client({
webSocketFactory: () => new SockJS("/ws"),
reconnectDelay: 5000,
heartbeatIncoming: 10000,
heartbeatOutgoing: 10000,
})
client.onConnect = () => {
// Subscribe to general forum channel
client.subscribe(`/topic/club.${clubId}.forum`, (message) => {
const data = JSON.parse(message.body)
if (data.type === "NEW_TOPIC" && onNewTopic) {
onNewTopic(data as ForumTopicEvent)
}
})
// Subscribe to specific topic if provided
if (topicId) {
client.subscribe(`/topic/club.${clubId}.forum.${topicId}`, (message) => {
const data = JSON.parse(message.body)
if (data.type === "NEW_REPLY" && onNewReply) {
onNewReply(data as ForumReplyEvent)
}
})
}
}
client.activate()
stompClientRef.current = client
} catch (error) {
console.warn("WebSocket connection failed:", error)
}
}
connectWebSocket()
return () => {
if (stompClientRef.current) {
stompClientRef.current.deactivate()
}
}
}, [clubId, topicId, onNewTopic, onNewReply])
}
export interface ForumTopicEvent {
type: "NEW_TOPIC"
topicId: string
title: string
authorName: string
timestamp: string
}
export interface ForumReplyEvent {
type: "NEW_REPLY"
topicId: string
replyId: string
authorName: string
timestamp: string
}
@@ -0,0 +1,62 @@
"use client"
import { useEffect, useRef } from "react"
/**
* Hook to subscribe to info board WebSocket events for a specific club.
* Pushes new post notifications to connected members in real-time.
*/
export function useInfoBoardSubscription(
clubId: string | undefined,
onNewPost?: (data: InfoBoardPostEvent) => void
) {
const stompClientRef = useRef<any>(null)
useEffect(() => {
if (!clubId) return
const connectWebSocket = async () => {
try {
const SockJS = (await import("sockjs-client")).default
const { Client } = await import("@stomp/stompjs")
const client = new Client({
webSocketFactory: () => new SockJS("/ws"),
reconnectDelay: 5000,
heartbeatIncoming: 10000,
heartbeatOutgoing: 10000,
})
client.onConnect = () => {
client.subscribe(`/topic/club.${clubId}.infoboard`, (message) => {
const data = JSON.parse(message.body)
if (data.type === "NEW_POST" && onNewPost) {
onNewPost(data as InfoBoardPostEvent)
}
})
}
client.activate()
stompClientRef.current = client
} catch (error) {
console.warn("WebSocket connection failed:", error)
}
}
connectWebSocket()
return () => {
if (stompClientRef.current) {
stompClientRef.current.deactivate()
}
}
}, [clubId, onNewPost])
}
export interface InfoBoardPostEvent {
type: "NEW_POST"
postId: string
title: string
category: string
timestamp: string
}