mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
event: add helper to get remaining mute duration
This commit is contained in:
parent
dd778ae0cd
commit
97da8eb44d
1 changed files with 12 additions and 0 deletions
|
|
@ -105,3 +105,15 @@ func (bmec *BeeperMuteEventContent) GetMutedUntilTime() time.Time {
|
|||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (bmec *BeeperMuteEventContent) GetMuteDuration() time.Duration {
|
||||
ts := bmec.GetMutedUntilTime()
|
||||
now := time.Now()
|
||||
if ts.Before(now) {
|
||||
return 0
|
||||
} else if ts == MutedForever {
|
||||
return -1
|
||||
} else {
|
||||
return ts.Sub(now)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue