mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
event: fix 32-bit compatibility
This commit is contained in:
parent
5d87d14b88
commit
ee1e05c3e8
1 changed files with 6 additions and 2 deletions
|
|
@ -132,14 +132,18 @@ func (pl *PowerLevelsEventContent) GetUserLevel(userID id.UserID) int {
|
|||
return level
|
||||
}
|
||||
|
||||
const maxPL = 1<<53 - 1
|
||||
|
||||
func (pl *PowerLevelsEventContent) SetUserLevel(userID id.UserID, level int) {
|
||||
pl.usersLock.Lock()
|
||||
defer pl.usersLock.Unlock()
|
||||
if pl.isCreator(userID) {
|
||||
return
|
||||
}
|
||||
if level == math.MaxInt {
|
||||
level = 1<<53 - 1
|
||||
if level == math.MaxInt && maxPL < math.MaxInt {
|
||||
// Hack to avoid breaking on 32-bit systems (they're only slightly supported)
|
||||
x := int64(maxPL)
|
||||
level = int(x)
|
||||
}
|
||||
if level == pl.UsersDefault {
|
||||
delete(pl.Users, userID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue