mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Added the list_topics and list_nodes role flags, Filtered the nodes listed by the roles
- `list_topics` / `list_nodes`: listing answers every topic, every node with messages, without reading any (`query` gives both). - Without them, listing nodes only answers those with messages in the topics the roles may read (every node until now). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,14 @@ pub struct Role {
|
||||
/// Whether it may run read-only SQL, which reads every topic.
|
||||
#[serde(default)]
|
||||
pub query: bool,
|
||||
/// Whether listing topics answers every topic with messages, not only
|
||||
/// those it may push to or read.
|
||||
#[serde(default)]
|
||||
pub list_topics: bool,
|
||||
/// Whether listing nodes answers every node with messages, not only
|
||||
/// those of the topics it may read.
|
||||
#[serde(default)]
|
||||
pub list_nodes: bool,
|
||||
/// Replication: the topics sent to it.
|
||||
#[serde(default)]
|
||||
pub send_topics: NameList,
|
||||
@@ -109,6 +117,17 @@ impl Permissions {
|
||||
self.roles.iter().any(|role| role.query)
|
||||
}
|
||||
|
||||
/// Whether listing topics answers every one: `list_topics`, or
|
||||
/// `query` (which reads them all anyway).
|
||||
pub fn lists_every_topic(&self) -> bool {
|
||||
self.roles.iter().any(|role| role.list_topics || role.query)
|
||||
}
|
||||
|
||||
/// Whether listing nodes answers every one: `list_nodes`, or `query`.
|
||||
pub fn lists_every_node(&self) -> bool {
|
||||
self.roles.iter().any(|role| role.list_nodes || role.query)
|
||||
}
|
||||
|
||||
/// Whether `node`'s messages in `topic` are sent to it.
|
||||
pub fn sends(&self, topic: &str, node: &str) -> bool {
|
||||
self.roles
|
||||
|
||||
Reference in New Issue
Block a user