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

@@ -386,6 +386,7 @@ func TestHandleMsgMhfSendMail_Direct(t *testing.T) {
server := createMockServer()
mock := &mockMailRepo{}
server.mailRepo = mock
ensureMailService(server)
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfSendMail{
@@ -436,6 +437,7 @@ func TestHandleMsgMhfSendMail_Guild(t *testing.T) {
}
server.mailRepo = mailMock
server.guildRepo = guildMock
ensureMailService(server)
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfSendMail{
@@ -470,6 +472,7 @@ func TestHandleMsgMhfSendMail_GuildNotFound(t *testing.T) {
guildMock := &mockGuildRepoForMail{getErr: errNotFound}
server.mailRepo = mailMock
server.guildRepo = guildMock
ensureMailService(server)
session := createMockSession(1, server)
pkt := &mhfpacket.MsgMhfSendMail{