feat(listsessions): add join/leave buttons for players
Deploy Telegram Bot / build-and-push (push) Successful in 21m33s
Deploy Telegram Bot / scan-images (push) Successful in 8m55s
Deploy Telegram Bot / deploy (push) Successful in 2m3s

For non-managers /listsessions now shows player-friendly actions:
-  Записаться <date> when not registered
- ✖️ Выйти <date> when already active
- ✖️ Выйти из ожидания <date> when waitlisted

Extend SessionListItemDto and the shared SQL query with IsUserActive
and IsUserWaitlisted flags so the renderer can choose the right button.
Update tests to cover all three player states.
This commit is contained in:
2026-06-15 15:05:12 +03:00
parent e15652399b
commit a391c51761
3 changed files with 135 additions and 8 deletions
@@ -20,7 +20,9 @@ public sealed class SessionListMessageRendererTests
4,
3,
1,
true)
true,
false,
false)
};
var text = SessionListMessageRenderer.RenderText(sessions);
@@ -41,22 +43,83 @@ public sealed class SessionListMessageRendererTests
}
[Fact]
public void Render_ShouldHideManagerActions_WhenUserCannotManage()
public void Render_ShouldIncludeJoinAction_WhenPlayerIsNotRegistered()
{
var sessionId = Guid.NewGuid();
var sessions = new[]
{
new SessionListItemDto(
Guid.NewGuid(),
sessionId,
"Ravenloft",
new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc),
SessionStatus.Planned,
4,
3,
0,
false,
false,
false)
};
var actions = SessionListMessageRenderer.RenderActions(sessions);
var shortDate = new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc).FormatMoscowShort();
Assert.Single(actions);
Assert.Contains(actions, a => a.Payload == $"join_session:{sessionId}");
Assert.Contains(actions, a => a.Label == $"✅ Записаться {shortDate}");
}
[Fact]
public void Render_ShouldIncludeLeaveAction_WhenPlayerIsActive()
{
var sessionId = Guid.NewGuid();
var sessions = new[]
{
new SessionListItemDto(
sessionId,
"Ravenloft",
new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc),
SessionStatus.Planned,
4,
3,
0,
false,
true,
false)
};
var actions = SessionListMessageRenderer.RenderActions(sessions);
var shortDate = new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc).FormatMoscowShort();
Assert.Single(actions);
Assert.Contains(actions, a => a.Payload == $"leave_session:{sessionId}");
Assert.Contains(actions, a => a.Label == $"✖️ Выйти {shortDate}");
}
[Fact]
public void Render_ShouldIncludeLeaveWaitlistAction_WhenPlayerIsWaitlisted()
{
var sessionId = Guid.NewGuid();
var sessions = new[]
{
new SessionListItemDto(
sessionId,
"Ravenloft",
new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc),
SessionStatus.Planned,
4,
3,
1,
false)
false,
false,
true)
};
var actions = SessionListMessageRenderer.RenderActions(sessions);
Assert.Empty(actions);
var shortDate = new DateTime(2026, 5, 7, 16, 30, 0, DateTimeKind.Utc).FormatMoscowShort();
Assert.Single(actions);
Assert.Contains(actions, a => a.Payload == $"leave_session:{sessionId}");
Assert.Contains(actions, a => a.Label == $"✖️ Выйти из ожидания {shortDate}");
}
}