mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-05 07:36:03 +02:00
feat: add /meta command for channel metadata retrieval
- Implemented the `/meta` command to fetch and display channel metadata including room ID, topic, message count, unique user count, estimated size, and protection level. - Added `ChannelMetaDto` to encapsulate channel metadata. - Updated `ChannelsController` to handle the new `/meta` endpoint. - Introduced `UploadLimits` configuration for admin-defined upload size limits for files, images, audio, and avatars. - Enhanced error handling and user feedback for metadata retrieval. - Updated documentation to reflect changes in encryption and room metadata. - Added tests for the new functionality and upload limits.
This commit is contained in:
@@ -127,6 +127,7 @@ public sealed class AppOrchestrator : IDisposable
|
||||
_commandHandler.OnLeaveChannel += HandleCmdLeaveChannel;
|
||||
_commandHandler.OnSetTopic += HandleCmdSetTopic;
|
||||
_commandHandler.OnListUsers += HandleCmdListUsers;
|
||||
_commandHandler.OnRoomInfo += HandleCmdMeta;
|
||||
_commandHandler.OnKickUser += HandleCmdKickUser;
|
||||
_commandHandler.OnBanUser += HandleCmdBanUser;
|
||||
_commandHandler.OnUnbanUser += HandleCmdUnbanUser;
|
||||
@@ -611,6 +612,46 @@ public sealed class AppOrchestrator : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleCmdMeta()
|
||||
{
|
||||
if (!_conn.IsConnected || _conn.Api is null) return;
|
||||
|
||||
var channel = _mainWindow.CurrentChannel;
|
||||
if (string.IsNullOrEmpty(channel)) return;
|
||||
|
||||
try
|
||||
{
|
||||
var meta = await _conn.Api.GetChannelMetaAsync(channel);
|
||||
if (meta is null)
|
||||
{
|
||||
InvokeUI(() => _mainWindow.ShowError($"Channel #{channel} not found."));
|
||||
return;
|
||||
}
|
||||
|
||||
var size = meta.EstimatedSizeBytes <= 0 ? "0 B" : ChatMessageManager.FormatFileSize(meta.EstimatedSizeBytes);
|
||||
var protection = meta.IsEncrypted ? "end-to-end encrypted"
|
||||
: meta.IsProtected ? "password-protected"
|
||||
: "open";
|
||||
|
||||
InvokeUI(() =>
|
||||
{
|
||||
_messageManager.AddSystemMessage(channel, $"Room info for #{meta.Name}:");
|
||||
if (!string.IsNullOrWhiteSpace(meta.Topic))
|
||||
_messageManager.AddSystemMessage(channel, $" Topic {meta.Topic}");
|
||||
_messageManager.AddSystemMessage(channel, $" Room ID {meta.Id}");
|
||||
_messageManager.AddSystemMessage(channel, $" Created {meta.CreatedAt.ToLocalTime():g}");
|
||||
_messageManager.AddSystemMessage(channel, $" Messages {meta.MessageCount}");
|
||||
_messageManager.AddSystemMessage(channel, $" Unique users {meta.UniqueUserCount}");
|
||||
_messageManager.AddSystemMessage(channel, $" Est. size {size}");
|
||||
_messageManager.AddSystemMessage(channel, $" Protection {protection}");
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InvokeUI(() => _mainWindow.ShowError($"Failed to fetch room info: {ex.Message}"));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleCmdKickUser(string username, string? reason)
|
||||
{
|
||||
if (!_conn.IsAuthenticated) return;
|
||||
|
||||
Reference in New Issue
Block a user