refactor(mail): extract mail logic into MailService

Introduce MailService as a convenience layer between handlers/services
and MailRepo. Provides Send, SendSystem, SendGuildInvite, and
BroadcastToGuild methods that encapsulate the boolean flag combinations.

GuildService now depends on MailService instead of MailRepo directly,
simplifying its mail-sending calls from verbose SendMail(..., false, true)
to clean SendSystem(recipientID, subject, body).

Guild mail broadcast logic moved from handleMsgMhfSendMail into
MailService.BroadcastToGuild.
This commit is contained in:
Houmgaor
2026-02-24 00:05:56 +01:00
parent 1e9de7920d
commit 077c08fd49
9 changed files with 292 additions and 64 deletions

View File

@@ -55,10 +55,17 @@ func createMockServer() *Server {
return s
}
// ensureMailService wires the MailService from the server's current repos.
// Call this after setting mailRepo and guildRepo on the mock server.
func ensureMailService(s *Server) {
s.mailService = NewMailService(s.mailRepo, s.guildRepo, s.logger)
}
// ensureGuildService wires the GuildService from the server's current repos.
// Call this after setting guildRepo, mailRepo, and charRepo on the mock server.
func ensureGuildService(s *Server) {
s.guildService = NewGuildService(s.guildRepo, s.mailRepo, s.charRepo, s.logger)
ensureMailService(s)
s.guildService = NewGuildService(s.guildRepo, s.mailService, s.charRepo, s.logger)
}
// ensureAchievementService wires the AchievementService from the server's current repos.