feat(guild): MyPage guild_notification + load_index audit
- Replace GuildNotification TODO stub in MyPageController.Index with BuildGuildNotificationAsync: populates guild_id, guild_room_message_id, is_join_request, is_invited from real DB state. - Inject IGuildService, IGuildInviteRepository, IGuildJoinRequestRepository, IGuildChatMessageRepository into MyPageController. - Add GetMaxMessageIdSafelyAsync to IGuildChatMessageRepository (returns null when no messages exist, vs GetMaxMessageIdAsync which returns 0). - LoadDetail.cs audit: grep returned no guild fields — no LoadController changes. - Add GuildCrossSurfaceTests (4 tests): guild member, pending invite, pending join request, no-guild viewer all verified green. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,8 +4,10 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SVSim.Database.Models;
|
||||
using SVSim.Database.Models.Config;
|
||||
using SVSim.Database.Repositories.Globals;
|
||||
using SVSim.Database.Repositories.Guild;
|
||||
using SVSim.Database.Repositories.Viewer;
|
||||
using SVSim.Database.Services;
|
||||
using SVSim.Database.Services.Guild;
|
||||
using SVSim.EmulatedEntrypoint.Constants;
|
||||
using SVSim.EmulatedEntrypoint.Infrastructure;
|
||||
using SVSim.EmulatedEntrypoint.Models.Dtos;
|
||||
@@ -31,10 +33,16 @@ public class MyPageController : SVSimController
|
||||
private readonly IArenaTwoPickRunRepository _arenaTwoPickRuns;
|
||||
private readonly IHomeDialogSessionTracker _homeDialogTracker;
|
||||
private readonly ILoginBonusService _loginBonus;
|
||||
private readonly IGuildService _guild;
|
||||
private readonly IGuildInviteRepository _invites;
|
||||
private readonly IGuildJoinRequestRepository _joinRequests;
|
||||
private readonly IGuildChatMessageRepository _chat;
|
||||
|
||||
public MyPageController(IViewerRepository viewerRepository, IGlobalsRepository globalsRepository,
|
||||
IGameConfigService config, IArenaTwoPickRunRepository arenaTwoPickRuns,
|
||||
IHomeDialogSessionTracker homeDialogTracker, ILoginBonusService loginBonus)
|
||||
IHomeDialogSessionTracker homeDialogTracker, ILoginBonusService loginBonus,
|
||||
IGuildService guild, IGuildInviteRepository invites,
|
||||
IGuildJoinRequestRepository joinRequests, IGuildChatMessageRepository chat)
|
||||
{
|
||||
_viewerRepository = viewerRepository;
|
||||
_globalsRepository = globalsRepository;
|
||||
@@ -42,6 +50,10 @@ public class MyPageController : SVSimController
|
||||
_arenaTwoPickRuns = arenaTwoPickRuns;
|
||||
_homeDialogTracker = homeDialogTracker;
|
||||
_loginBonus = loginBonus;
|
||||
_guild = guild;
|
||||
_invites = invites;
|
||||
_joinRequests = joinRequests;
|
||||
_chat = chat;
|
||||
}
|
||||
|
||||
[HttpPost("index")]
|
||||
@@ -90,7 +102,7 @@ public class MyPageController : SVSimController
|
||||
ReceiveFriendApplyCount = 0, // TODO(mypage-stub): viewer friend-request inbox
|
||||
UnreadPresentCount = 0, // TODO(mypage-stub): viewer presents/mail
|
||||
FriendBattleInviteCount = 0, // TODO(mypage-stub): viewer room-invite count
|
||||
GuildNotification = new GuildNotification(), // TODO(mypage-stub): viewer guild state
|
||||
GuildNotification = await BuildGuildNotificationAsync(viewer.Id, HttpContext.RequestAborted),
|
||||
LastAnnounceId = 0, // TODO(mypage-stub): globals announcement metadata
|
||||
LastAnnounceUpdateTime = string.Empty, // TODO(mypage-stub): globals announcement metadata
|
||||
FeatureMaintenanceList = new(), // TODO(mypage-stub): FeatureMaintenanceEntry rows
|
||||
@@ -188,6 +200,20 @@ public class MyPageController : SVSimController
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<GuildNotification> BuildGuildNotificationAsync(long viewerId, CancellationToken ct)
|
||||
{
|
||||
var view = await _guild.GetMyGuildAsync(viewerId, ct);
|
||||
var inviteCount = await _invites.CountPendingForInviteeAsync(viewerId, ct);
|
||||
var joinReqHasPending = (await _joinRequests.ListPendingForViewerAsync(viewerId, ct)).Count > 0;
|
||||
return new GuildNotification
|
||||
{
|
||||
GuildId = view?.Guild.GuildId,
|
||||
GuildRoomMessageId = view is null ? null : await _chat.GetMaxMessageIdSafelyAsync(view.Guild.GuildId, ct),
|
||||
IsJoinRequest = joinReqHasPending,
|
||||
IsInvited = inviteCount > 0,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors LoadController.BuildArenaInfosAsync. /mypage/index has no Keys.Contains("arena_info")
|
||||
/// guard (ArenaData(jsonData["arena_info"]) at MyPageTask.cs:55 indexes [0] unconditionally), and
|
||||
|
||||
Reference in New Issue
Block a user