NickServ: add SET HIDE STATUS for last-seen privacy
Lets an account keep its last-seen/online line in INFO visible only to itself and to opers. Default stays public (Anope's default). Accepts STATUS (with USERMASK as an alias) per Anope's SET HIDE <field> grammar.
This commit is contained in:
parent
39d7421c06
commit
053f8cf832
12 changed files with 116 additions and 19 deletions
|
|
@ -21,7 +21,7 @@ impl Db {
|
|||
ajoin: Vec::new(),
|
||||
suspension: None,
|
||||
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
|
||||
greet: String::new(), no_autoop: false, no_protect: false,
|
||||
greet: String::new(), no_autoop: false, no_protect: false, hide_status: false,
|
||||
vhost: None,
|
||||
vhost_request: None,
|
||||
last_seen: now(),
|
||||
|
|
@ -60,7 +60,7 @@ impl Db {
|
|||
ajoin: Vec::new(),
|
||||
suspension: None,
|
||||
memos: Vec::new(), memo_ignore: Vec::new(), memo_notify: true, memo_limit: None,
|
||||
greet: String::new(), no_autoop: false, no_protect: false,
|
||||
greet: String::new(), no_autoop: false, no_protect: false, hide_status: false,
|
||||
vhost: None,
|
||||
vhost_request: None,
|
||||
last_seen: now(),
|
||||
|
|
@ -450,6 +450,22 @@ impl Db {
|
|||
self.accounts.get(&key(account)).is_none_or(|a| !a.no_protect)
|
||||
}
|
||||
|
||||
/// Set whether `account` hides its last-seen/online line from other users.
|
||||
pub fn set_account_hide_status(&mut self, account: &str, on: bool) -> Result<(), RegError> {
|
||||
let k = key(account);
|
||||
if !self.accounts.contains_key(&k) {
|
||||
return Err(RegError::Internal);
|
||||
}
|
||||
self.log.append(Event::AccountHideStatusSet { account: account.to_string(), on }).map_err(|_| RegError::Internal)?;
|
||||
self.accounts.get_mut(&k).unwrap().hide_status = on;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether `account` hides its last-seen/online line from others (default false).
|
||||
pub fn account_hides_status(&self, account: &str) -> bool {
|
||||
self.accounts.get(&key(account)).is_some_and(|a| a.hide_status)
|
||||
}
|
||||
|
||||
/// Replace `account`'s password with freshly derived credentials.
|
||||
pub fn set_credentials(&mut self, account: &str, creds: Credentials) -> Result<(), RegError> {
|
||||
let k = key(account);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue