Revoke 'until death' consent on death.
This commit is contained in:
parent
3f6419e5f8
commit
158b590c35
@ -744,6 +744,16 @@ impl DBTrans {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn revoke_until_death_consent(&self, party: &str) -> DResult<()> {
|
||||
self.pg_trans()?.execute(
|
||||
"DELETE FROM user_consent WHERE (consenting_user = $1 OR \
|
||||
(consented_user = $1 AND consent_type = 'fight')) AND \
|
||||
details->>'until_death'='true'",
|
||||
&[&party]
|
||||
).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_expired_user_consent(&self) -> DResult<()> {
|
||||
self.pg_trans()?.execute(
|
||||
"DELETE FROM user_consent WHERE details->>'expires' < $1",
|
||||
|
@ -126,7 +126,7 @@ static REGISTERED_HELP_PAGES: phf::Map<&'static str, &'static str> = phf_map! {
|
||||
\n\
|
||||
To allow, an individual, use the syntax <bold>allow <reset>type <bold>from <reset>player options\n\
|
||||
Options can be blank to use defaults, or can be one or more of the following, separated by spaces:\n\
|
||||
\t<bold>until<reset> n <bold>minutes<reset> - replace n with a number. You can use hours, days, or weeks instead of minutes. This makes the consent expire. Fight expires after a week if you don't give a shorter period, and all other consent types have no expiry unless you specify one.\n\
|
||||
\t<bold>for<reset> n <bold>minutes<reset> - replace n with a number. You can use hours, days, or weeks instead of minutes. This makes the consent expire. Fight expires after a week if you don't give a shorter period, and all other consent types have no expiry unless you specify one.\n\
|
||||
\t<bold>until death<reset> - makes the consent valid only until you next die.\n\
|
||||
\t<bold>allow private<reset> - makes the consent valid even in privately owned places. This is the default for anything except fight.\n\
|
||||
\t<bold>disallow private<reset> - the opposite of allow private.\n\
|
||||
|
@ -179,7 +179,7 @@ pub fn parse_allow<'l>(input: &'l str, is_explicit: bool) -> Result<AllowCommand
|
||||
}
|
||||
"until" => {
|
||||
let (tok, new_input) = match new_input.split_once(" ") {
|
||||
None => (input, ""),
|
||||
None => (new_input, ""),
|
||||
Some(v) => v
|
||||
};
|
||||
if tok.trim_start().to_lowercase() != "death" {
|
||||
|
@ -242,6 +242,8 @@ pub async fn handle_death(trans: &DBTrans, whom: &mut Item) -> DResult<()> {
|
||||
npc_code: whom.item_code.clone()
|
||||
}
|
||||
}).await?;
|
||||
} else if whom.item_type == "player" {
|
||||
trans.revoke_until_death_consent(&whom.item_code).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user