Структура, доп модули, федерация, документация

This commit is contained in:
Халимов Рустам
2026-03-27 00:55:01 +03:00
parent 7cb6ac61dd
commit 7ef73b414c
64 changed files with 3080 additions and 133 deletions

View File

@@ -1,26 +1,159 @@
using Knot.Shared.Kernel.Configuration;
using System.Collections.Generic;
namespace Knot.Modules.Settings.Application.Config.DTOs;
public record PublicConfigDto
{
public bool EnableCalls { get; init; }
public bool EnableKlipy { get; init; }
public int MaxFileSizeMb { get; init; }
public int MaxGroupMembers { get; init; }
public bool EnableConfederation { get; init; }
public bool EnableRegistration { get; init; }
public SystemConfigDto System { get; init; } = new();
public StoriesConfigDto Stories { get; init; } = new();
public ChatsConfigDto Chats { get; init; } = new();
public MessagesConfigDto Messages { get; init; } = new();
public WebRtcConfigDto WebRtc { get; init; } = new();
public KlipyConfigDto Klipy { get; init; } = new();
public ImportConfigDto Import { get; init; } = new();
public FederationConfigDto Federation { get; init; } = new();
public static PublicConfigDto FromSettings(SystemSettingsDto settings)
{
return new PublicConfigDto
{
EnableCalls = settings.EnableCalls,
EnableKlipy = settings.EnableKlipy,
MaxFileSizeMb = settings.MaxFileSizeMb,
MaxGroupMembers = settings.MaxGroupMembers,
EnableConfederation = settings.EnableConfederation,
EnableRegistration = settings.EnableRegistration
System = new SystemConfigDto
{
DomainUrl = settings.System.DomainUrl,
EnableRegistration = settings.System.EnableRegistration
},
Stories = new StoriesConfigDto
{
Enabled = settings.Stories.Enabled,
MaxStoriesPerPeriod = settings.Stories.MaxStoriesPerPeriod,
StoryLifetimeHours = settings.Stories.StoryLifetimeHours,
TextStoriesEnabled = settings.Stories.TextStoriesEnabled,
TextStoryDurationSeconds = settings.Stories.TextStoryDurationSeconds,
MediaStoryMaxDurationSeconds = settings.Stories.MediaStoryMaxDurationSeconds,
MaxMediaSizeBytes = settings.Stories.MaxMediaSizeBytes
},
Chats = new ChatsConfigDto
{
SupportGroups = settings.Chats.SupportGroups,
MaxGroupParticipants = settings.Chats.MaxGroupParticipants,
AllowChatToGroupConversion = settings.Chats.AllowChatToGroupConversion,
EnableFolders = settings.Chats.EnableFolders
},
Messages = new MessagesConfigDto
{
DailyMessageLimitPerUser = settings.Messages.DailyMessageLimitPerUser,
ChatMessageLimit = settings.Messages.ChatMessageLimit,
AllowMedia = settings.Messages.AllowMedia,
MaxMediaSizeBytes = settings.Messages.MaxMediaSizeBytes,
AllowedMediaTypes = settings.Messages.AllowedMediaTypes,
AllowVoiceMessages = settings.Messages.AllowVoiceMessages,
AllowForwarding = settings.Messages.AllowForwarding,
AllowReactions = settings.Messages.AllowReactions,
AllowReplies = settings.Messages.AllowReplies,
AllowQuoting = settings.Messages.AllowQuoting,
AllowMessageDeletion = settings.Messages.AllowMessageDeletion,
ForbidCopying = settings.Messages.ForbidCopying,
AllowLinks = settings.Messages.AllowLinks,
AllowPolls = settings.Messages.AllowPolls,
AllowPinning = settings.Messages.AllowPinning
},
WebRtc = new WebRtcConfigDto
{
Enabled = settings.WebRtc.Enabled,
EnableVoiceCalls = settings.WebRtc.EnableVoiceCalls,
EnableVideoCalls = settings.WebRtc.EnableVideoCalls,
EnableScreenSharing = settings.WebRtc.EnableScreenSharing,
TurnHost = settings.WebRtc.TurnHost,
TurnPort = settings.WebRtc.TurnPort
},
Klipy = new KlipyConfigDto
{
Enabled = settings.Klipy.Enabled,
AppName = settings.Klipy.AppName
},
Import = new ImportConfigDto
{
EnableTelegramImport = settings.Import.EnableTelegramImport
},
Federation = new FederationConfigDto
{
Enabled = settings.Federation.Enabled,
ServerDescription = settings.Federation.ServerDescription,
AllowedDomains = settings.Federation.AllowedDomains
}
};
}
}
public record SystemConfigDto
{
public string DomainUrl { get; init; } = string.Empty;
public bool EnableRegistration { get; init; }
}
public record StoriesConfigDto
{
public bool Enabled { get; init; }
public int MaxStoriesPerPeriod { get; init; }
public int StoryLifetimeHours { get; init; }
public bool TextStoriesEnabled { get; init; }
public int TextStoryDurationSeconds { get; init; }
public int MediaStoryMaxDurationSeconds { get; init; }
public int MaxMediaSizeBytes { get; init; }
}
public record ChatsConfigDto
{
public bool SupportGroups { get; init; }
public int MaxGroupParticipants { get; init; }
public bool AllowChatToGroupConversion { get; init; }
public bool EnableFolders { get; init; }
}
public record MessagesConfigDto
{
public int DailyMessageLimitPerUser { get; init; }
public int ChatMessageLimit { get; init; }
public bool AllowMedia { get; init; }
public int MaxMediaSizeBytes { get; init; }
public List<string> AllowedMediaTypes { get; init; } = new();
public bool AllowVoiceMessages { get; init; }
public bool AllowForwarding { get; init; }
public bool AllowReactions { get; init; }
public bool AllowReplies { get; init; }
public bool AllowQuoting { get; init; }
public bool AllowMessageDeletion { get; init; }
public bool ForbidCopying { get; init; }
public bool AllowLinks { get; init; }
public bool AllowPolls { get; init; }
public bool AllowPinning { get; init; }
}
public record WebRtcConfigDto
{
public bool Enabled { get; init; }
public bool EnableVoiceCalls { get; init; }
public bool EnableVideoCalls { get; init; }
public bool EnableScreenSharing { get; init; }
public string TurnHost { get; init; } = string.Empty;
public int TurnPort { get; init; }
}
public record KlipyConfigDto
{
public bool Enabled { get; init; }
public string AppName { get; init; } = string.Empty;
}
public record ImportConfigDto
{
public bool EnableTelegramImport { get; init; }
}
public record FederationConfigDto
{
public bool Enabled { get; init; }
public string ServerDescription { get; init; } = string.Empty;
public List<FederationDomainConfig> AllowedDomains { get; init; } = new();
}