refactor(guild_chat): extract chat-user lookup to viewer repo; fix NEW-direction exclusivity
Add ChatUserProfile record and IViewerRepository.LoadChatProfilesAsync (AsNoTracking, projects Name/EmblemId/CountryCode/Rank/DegreeId from Viewer+Info nav refs). GuildChatController.Messages now injects IViewerRepository instead of SVSimDbContext; calls LoadChatProfilesAsync to populate users[] (removes direct db access from controller). GuildChatMessageRepository direction=2 (NEW): change >= start to > start (exclusive). GuildChatPollTests updated to assert the start message is NOT returned by direction=NEW. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -193,24 +193,32 @@ public class GuildChatPollTests
|
||||
viewer_id = Vid, steam_id = Sid, steam_session_ticket = Stk
|
||||
}));
|
||||
|
||||
// Poll NEW from createGuildMsgId — should return only the Join message
|
||||
// Poll NEW from createGuildMsgId — should return only the Join message (exclusive: > start)
|
||||
var newPoll = await PollAsync(leaderClient, startMessageId: createGuildMsgId, direction: 2 /* NEW */);
|
||||
var newMsgs = newPoll.GetProperty("chat_message");
|
||||
|
||||
// direction=NEW returns messages with message_id >= start, but since we want > start
|
||||
// the repository uses ">= start" for NEW. In practice the first NEW msg returned includes
|
||||
// the start message itself if it exists, plus newer ones. Let's verify Join is present.
|
||||
// direction=NEW uses strict > (exclusive): the CreateGuild message at message_id=createGuildMsgId
|
||||
// must NOT appear; only messages with message_id strictly greater than start are returned.
|
||||
bool hasCreateGuild = false;
|
||||
bool hasJoin = false;
|
||||
for (int i = 0; i < newMsgs.GetArrayLength(); i++)
|
||||
{
|
||||
if (GetStringifiedInt(newMsgs[i], "message_type") == (int)GuildChatMessageType.Join)
|
||||
int msgType = GetStringifiedInt(newMsgs[i], "message_type");
|
||||
long msgId = GetStringifiedLong(newMsgs[i], "message_id");
|
||||
if (msgType == (int)GuildChatMessageType.CreateGuild)
|
||||
hasCreateGuild = true;
|
||||
if (msgType == (int)GuildChatMessageType.Join)
|
||||
{
|
||||
hasJoin = true;
|
||||
// Its message_id must be > createGuildMsgId
|
||||
Assert.That(GetStringifiedLong(newMsgs[i], "message_id"), Is.GreaterThan(createGuildMsgId),
|
||||
Assert.That(msgId, Is.GreaterThan(createGuildMsgId),
|
||||
"Join message_id must be greater than the CreateGuild id");
|
||||
}
|
||||
// Every returned message must have message_id strictly > start (exclusive semantics)
|
||||
Assert.That(msgId, Is.GreaterThan(createGuildMsgId),
|
||||
$"direction=NEW must be exclusive: message_id {msgId} must be > start {createGuildMsgId}");
|
||||
}
|
||||
Assert.That(hasCreateGuild, Is.False,
|
||||
"direction=NEW (exclusive) must NOT include the message at start itself");
|
||||
Assert.That(hasJoin, Is.True, "direction=NEW poll must include the Join message");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user