43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using GmRelay.Shared.Domain;
|
|
|
|
namespace GmRelay.Bot.Features.Confirmation.HandleRsvp;
|
|
|
|
internal sealed record RsvpFlowDecision(
|
|
string CallbackText,
|
|
bool ShouldAlertGm,
|
|
bool ShouldRevertSessionToConfirmationSent,
|
|
bool ShouldMarkSessionConfirmed,
|
|
bool ShouldNotifyGroup,
|
|
bool ShouldNotifyGm);
|
|
|
|
internal static class RsvpFlowRules
|
|
{
|
|
public static RsvpFlowDecision Evaluate(
|
|
string requestedStatus,
|
|
string currentSessionStatus,
|
|
int totalParticipants,
|
|
int confirmedParticipants)
|
|
{
|
|
if (requestedStatus == RsvpStatus.Declined)
|
|
{
|
|
return new RsvpFlowDecision(
|
|
CallbackText: "\u0412\u044b \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043e\u0442 \u0443\u0447\u0430\u0441\u0442\u0438\u044f.",
|
|
ShouldAlertGm: true,
|
|
ShouldRevertSessionToConfirmationSent: currentSessionStatus == SessionStatus.Confirmed,
|
|
ShouldMarkSessionConfirmed: false,
|
|
ShouldNotifyGroup: false,
|
|
ShouldNotifyGm: false);
|
|
}
|
|
|
|
var everyoneConfirmed = confirmedParticipants == totalParticipants;
|
|
|
|
return new RsvpFlowDecision(
|
|
CallbackText: "\u0412\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u0438\u0435!",
|
|
ShouldAlertGm: false,
|
|
ShouldRevertSessionToConfirmationSent: false,
|
|
ShouldMarkSessionConfirmed: everyoneConfirmed,
|
|
ShouldNotifyGroup: everyoneConfirmed,
|
|
ShouldNotifyGm: everyoneConfirmed);
|
|
}
|
|
}
|