feat(guild): separate scout invitations into guild_invites table

Scout invitations were stored in guild_applications with type 'invited',
forcing the scout list response to use charID as the invitation ID — a
known hack that made CancelGuildScout semantically incorrect.

Introduce a dedicated guild_invites table (migration 0012) with a serial
PK. The scout list now returns real invite IDs and actual InvitedAt
timestamps. CancelGuildScout cancels by PK. AcceptInvite and DeclineInvite
operate on guild_invites while player-applied applications remain in
guild_applications unchanged.
This commit is contained in:
Houmgaor
2026-03-21 17:59:25 +01:00
parent a67b10abbc
commit dbbfb927f8
10 changed files with 230 additions and 135 deletions

View File

@@ -308,8 +308,10 @@ type mockGuildRepo struct {
removeErr error
createAppErr error
getMemberErr error
hasAppResult bool
hasAppErr error
hasAppResult bool
hasAppErr error
hasInviteResult bool
hasInviteErr error
listPostsErr error
createPostErr error
deletePostErr error
@@ -317,8 +319,10 @@ type mockGuildRepo struct {
// State tracking
disbandedID uint32
removedCharID uint32
acceptedCharID uint32
rejectedCharID uint32
acceptedCharID uint32
rejectedCharID uint32
acceptInviteCharID uint32
declineInviteCharID uint32
savedGuild *Guild
savedMembers []*GuildMember
createdAppArgs []interface{}
@@ -571,10 +575,19 @@ func (m *mockGuildRepo) CountGuildKills(_, _ uint32) (int, error) {
// No-op stubs for remaining GuildRepo interface methods.
func (m *mockGuildRepo) ListAll() ([]*Guild, error) { return nil, nil }
func (m *mockGuildRepo) Create(_ uint32, _ string) (int32, error) { return 0, nil }
func (m *mockGuildRepo) CreateApplicationWithMail(_, _, _ uint32, _ GuildApplicationType, _, _ uint32, _, _ string) error {
return nil
func (m *mockGuildRepo) CreateInviteWithMail(_, _, _, _, _ uint32, _, _ string) error { return nil }
func (m *mockGuildRepo) HasInvite(_, _ uint32) (bool, error) {
return m.hasInviteResult, m.hasInviteErr
}
func (m *mockGuildRepo) CancelInvite(_ uint32) error { return nil }
func (m *mockGuildRepo) AcceptInvite(_, charID uint32) error {
m.acceptInviteCharID = charID
return m.acceptErr
}
func (m *mockGuildRepo) DeclineInvite(_, charID uint32) error {
m.declineInviteCharID = charID
return m.rejectErr
}
func (m *mockGuildRepo) CancelInvitation(_, _ uint32) error { return nil }
func (m *mockGuildRepo) ArrangeCharacters(_ []uint32) error { return nil }
func (m *mockGuildRepo) GetItemBox(_ uint32) ([]byte, error) { return nil, nil }
func (m *mockGuildRepo) SaveItemBox(_ uint32, _ []byte) error { return nil }
@@ -597,9 +610,7 @@ func (m *mockGuildRepo) CountNewPosts(_ uint32, _ time.Time) (int, error)
func (m *mockGuildRepo) ListAlliances() ([]*GuildAlliance, error) { return nil, nil }
func (m *mockGuildRepo) ClearTreasureHunt(_ uint32) error { return nil }
func (m *mockGuildRepo) InsertKillLog(_ uint32, _ int, _ uint8, _ time.Time) error { return nil }
func (m *mockGuildRepo) ListInvitedCharacters(_ uint32) ([]*ScoutedCharacter, error) {
return nil, nil
}
func (m *mockGuildRepo) ListInvites(_ uint32) ([]*GuildInvite, error) { return nil, nil }
func (m *mockGuildRepo) RolloverDailyRP(_ uint32, _ time.Time) error { return nil }
func (m *mockGuildRepo) AddWeeklyBonusUsers(_ uint32, _ uint8) error { return nil }