using Collaboration.Domain.Enums;
namespace Collaboration.Domain.Entities;
///
/// Per-organization configuration for the collaboration module.
/// All behaviour defaults are driven from here — nothing hardcoded.
///
public class CollabConfig
{
public Guid OrgId { get; private set; }
// Session limits
public int MaxParticipantsDefault { get; private set; }
public int MaxParticipantsAbsolute { get; private set; } // Hard ceiling regardless of session setting
public int SessionTimeoutMinutes { get; private set; } // Auto-abandon after inactivity
public int InviteLinkExpiryMinutes { get; private set; }
public int MaxScheduledSessionsPerUser { get; private set; }
// Feature toggles
public bool AllowScreenShare { get; private set; }
public bool AllowAnonymousJoin { get; private set; }
public bool AllowGuestJoinViaLink { get; private set; }
public bool EnableAuditLog { get; private set; }
public bool EnableCoBrowse { get; private set; }
public bool EnableInSessionChat { get; private set; }
public bool EnableAnnotations { get; private set; }
public bool EnableCursorBroadcast { get; private set; }
public bool EnableFormSync { get; private set; }
// Control handover
public ControlConsentMode ControlConsentMode { get; private set; }
///
/// JSON array of module codes allowed for session context.
/// Null = all modules allowed.
/// e.g. ["AP","HRMS","CRM"]
///
public string? AllowedModulesJson { get; private set; }
public DateTime CreatedAt { get; private set; }
public DateTime UpdatedAt { get; private set; }
private CollabConfig() { }
/// Creates a default config for a new org.
public static CollabConfig CreateDefault(Guid orgId)
{
return new CollabConfig
{
OrgId = orgId,
MaxParticipantsDefault = 10,
MaxParticipantsAbsolute = 25,
SessionTimeoutMinutes = 30,
InviteLinkExpiryMinutes = 60,
MaxScheduledSessionsPerUser = 20,
AllowScreenShare = true,
AllowAnonymousJoin = false,
AllowGuestJoinViaLink = true,
EnableAuditLog = true,
EnableCoBrowse = true,
EnableInSessionChat = true,
EnableAnnotations = true,
EnableCursorBroadcast = true,
EnableFormSync = true,
ControlConsentMode = ControlConsentMode.RoleDependent,
AllowedModulesJson = null,
CreatedAt = DateTime.UtcNow,
UpdatedAt = DateTime.UtcNow
};
}
public void Update(CollabConfigUpdateParams p)
{
MaxParticipantsDefault = Math.Min(p.MaxParticipantsDefault, MaxParticipantsAbsolute);
MaxParticipantsAbsolute = p.MaxParticipantsAbsolute;
SessionTimeoutMinutes = p.SessionTimeoutMinutes;
InviteLinkExpiryMinutes = p.InviteLinkExpiryMinutes;
MaxScheduledSessionsPerUser = p.MaxScheduledSessionsPerUser;
AllowScreenShare = p.AllowScreenShare;
AllowAnonymousJoin = p.AllowAnonymousJoin;
AllowGuestJoinViaLink = p.AllowGuestJoinViaLink;
EnableAuditLog = p.EnableAuditLog;
EnableCoBrowse = p.EnableCoBrowse;
EnableInSessionChat = p.EnableInSessionChat;
EnableAnnotations = p.EnableAnnotations;
EnableCursorBroadcast = p.EnableCursorBroadcast;
EnableFormSync = p.EnableFormSync;
ControlConsentMode = p.ControlConsentMode;
AllowedModulesJson = p.AllowedModulesJson;
UpdatedAt = DateTime.UtcNow;
}
}
/// Parameter object for CollabConfig.Update() — avoids long param lists.
public record CollabConfigUpdateParams(
int MaxParticipantsDefault,
int MaxParticipantsAbsolute,
int SessionTimeoutMinutes,
int InviteLinkExpiryMinutes,
int MaxScheduledSessionsPerUser,
bool AllowScreenShare,
bool AllowAnonymousJoin,
bool AllowGuestJoinViaLink,
bool EnableAuditLog,
bool EnableCoBrowse,
bool EnableInSessionChat,
bool EnableAnnotations,
bool EnableCursorBroadcast,
bool EnableFormSync,
ControlConsentMode ControlConsentMode,
string? AllowedModulesJson
);