Skip to content

Commit 88a3d9c

Browse files
committed
allow anyone to CLOSE in the withdraw period
1 parent deafe77 commit 88a3d9c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

sentry/src/access.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::Session;
1212
pub enum Error {
1313
OnlyCreatorCanCloseChannel,
1414
ChannelIsExpired,
15-
ChannelIsPastWithdrawPeriod,
15+
ChannelIsInWithdrawPeriod,
1616
RulesError(String),
1717
}
1818

@@ -28,21 +28,27 @@ pub async fn check_access(
2828
Event::Close => true,
2929
_ => false,
3030
};
31+
let current_time = Utc::now();
32+
let is_in_withdraw_period = current_time > channel.spec.withdraw_period_start;
3133

32-
// Check basic access rules
33-
// only the creator can send a CLOSE
34+
// We're only sending a CLOSE
35+
// That's allowed for the creator normally, and for everyone during the withdraw period
36+
if events.iter().all(is_close_event) && (session.uid == channel.creator || is_in_withdraw_period) {
37+
return Ok(());
38+
}
39+
40+
// Only the creator can send a CLOSE
3441
if session.uid != channel.creator && events.iter().any(is_close_event) {
3542
return Err(Error::OnlyCreatorCanCloseChannel);
3643
}
3744

38-
let current_time = Utc::now();
3945

4046
if current_time > channel.valid_until {
4147
return Err(Error::ChannelIsExpired);
4248
}
4349

44-
if current_time > channel.spec.withdraw_period_start && !events.iter().all(is_close_event) {
45-
return Err(Error::ChannelIsPastWithdrawPeriod);
50+
if is_in_withdraw_period {
51+
return Err(Error::ChannelIsInWithdrawPeriod);
4652
}
4753

4854
let default_rules = [

0 commit comments

Comments
 (0)