mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
* [Server] Gate room channels on privilege levels * [Server] Filter channel catalog per user, split read/write gating, add banners - Server_Room::getInfo() now takes the requesting user and only lists channels that user may read. Previously every room member received the full catalog (e.g. the moderators channel) while message delivery was already gated, so restricted channels were visible but silent. - Split channel access into mayReadChannel/mayWriteChannel: history replay, catalog listing, and event fan-out use the read level (access_level); Command_RoomChannelSay uses the write level (write_access_level, falling back to the read level when unset). - Plumb write_access_level and banner_message through both room sources (SQL rooms_channels table and config-file channels via writeaccess and banner keys). - Schema 38 -> 39: add write_access_level (NULL means inherit the read level) and banner_message columns; also widen access_level to the full six-value privilege enum to match the 37 -> 38 migration. * Fixup: evaluate channel access per user flag instead of ladder User flags are independent bits: IsDeveloper does not imply IsModerator/IsAdmin, so developer-only users must not reach moderator/admin channels. Replace the userPrivilegeLevel ladder with hasChannelPrivilege: moderator channels need IsModerator (admins hold it alongside IsAdmin), admin channels need IsAdmin, developer channels need IsDeveloper or IsAdmin, judge channels admit IsJudge/IsModerator. Covers catalog filtering, history replay, write gating and fan-out, and corrects the ini example and proto docs. * [Server] Make channel privilege helpers static per review * [Server] Fail closed on unknown channel access levels per review - roomChannelAccessFromKey returns nullopt for unknown keywords instead of silently falling back to Public - skip channels with unknown read/write levels with qWarning, empty read defaults to Public, empty write means no override - mayWriteChannel now also requires read access so write-below-read configs cannot post into invisible channels * [Server] Remove stray conflict marker in channel replay comment * [Server] Fix servatrice.cpp formatting per clang-format-18 --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de> Co-authored-by: BruebachL <bruebachl@cockatrice.example>
25 lines
1.3 KiB
Protocol Buffer
25 lines
1.3 KiB
Protocol Buffer
syntax = "proto2";
|
|
|
|
message ServerInfo_RoomChannel {
|
|
enum AccessLevel {
|
|
// Required user flag set, evaluated per level (not as a ladder):
|
|
// Registered needs IsRegistered; Judge needs IsJudge or IsModerator;
|
|
// Moderator needs IsModerator (admins hold it alongside IsAdmin);
|
|
// Admin needs IsAdmin; Developer needs IsDeveloper or IsAdmin.
|
|
Public = 0;
|
|
Registered = 1;
|
|
Judge = 2;
|
|
Moderator = 3;
|
|
Admin = 4;
|
|
Developer = 5;
|
|
}
|
|
optional string id = 1; // stable ASCII id, e.g. "deck-discussion"
|
|
optional string display_name = 2; // server-provided, localizable only server-side
|
|
optional AccessLevel access_level = 3 [default = Public]; // minimum privilege level required to read the channel
|
|
// Minimum privilege level required to write to the channel. When unset, writing requires the same level as
|
|
// reading. This allows read-mostly channels such as a developer news feed: readable by everyone, writable
|
|
// only by developers.
|
|
optional AccessLevel write_access_level = 4;
|
|
// Static banner shown at the top of the channel, analogous to the room join message on Main. Empty = none.
|
|
optional string banner_message = 5;
|
|
}
|