45 lines
1.9 KiB
C#
45 lines
1.9 KiB
C#
namespace RelayShared.Services;
|
|
|
|
/// <summary>
|
|
/// One row in the sidebar channel list. The server computes the permission-derived fields
|
|
/// (CanPost, CanManage) per-user so the client never has to evaluate permissions itself.
|
|
/// </summary>
|
|
public sealed class ChannelItem
|
|
{
|
|
/// <summary>Surreal record id (e.g. "channels:abc").</summary>
|
|
public string ChannelId { get; set; } = string.Empty;
|
|
|
|
/// <summary>Sidebar display name ("general", "welcome", etc.).</summary>
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
/// <summary>Drives icon and behavior: Text/Voice/File/Forum/Stage.</summary>
|
|
public ChannelType Type { get; set; }
|
|
|
|
/// <summary>Sidebar category label (e.g. "General"). Empty groups fall under a default "Channels" header.</summary>
|
|
public string Group { get; set; } = string.Empty;
|
|
|
|
/// <summary>Creation timestamp. Drives sidebar sort order (oldest → newest).</summary>
|
|
public DateTime CreatedAt { get; set; }
|
|
|
|
/// <summary>True if the channel is announcement-style (welcome, files). Drives the 🔒 suffix in the sidebar.</summary>
|
|
public bool IsReadOnly { get; set; }
|
|
|
|
/// <summary>Permission-resolved: can the receiving user send messages here. Drives input enable/disable.</summary>
|
|
public bool CanPost { get; set; }
|
|
|
|
/// <summary>Permission-resolved: can the receiving user edit/delete this channel. Drives context-menu visibility.</summary>
|
|
public bool CanManage { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Server-to-client channel list. Sent in response to WsAction.GetChannels and broadcast
|
|
/// to all sessions after every channel create / delete.
|
|
/// </summary>
|
|
public sealed class SocketChannelList
|
|
{
|
|
public SignalType Type { get; set; } = SignalType.ChannelList;
|
|
|
|
/// <summary>Channels the receiving user is allowed to view. Permission filtering happens server-side.</summary>
|
|
public List<ChannelItem> Channels { get; set; } = [];
|
|
}
|