diff options
author | 2024-06-06 09:38:02 -0700 | |
---|---|---|
committer | 2024-06-06 16:38:02 +0000 | |
commit | 5e2d4fdb19eb4fcd4c0bbfb3e2f29067a58c88c8 (patch) | |
tree | 607006af6b4bb63bb625b39f3ca0fe869eb6ba95 /internal/config | |
parent | [bugfix] update media if more than just url changes (#2970) (diff) | |
download | gotosocial-5e2d4fdb19eb4fcd4c0bbfb3e2f29067a58c88c8.tar.xz |
[feature] User muting (#2960)
* User muting
* Address review feedback
* Rename uniqueness constraint on user_mutes to match convention
* Remove unused account_id from where clause
* Add UserMute to NewTestDB
* Update test/envparsing.sh with new and fixed cache stuff
* Address tobi's review comments
* Make compiledUserMuteListEntry.expired consistent with UserMute.Expired
* Make sure mute_expires_at is serialized as an explicit null for indefinite mutes
---------
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/config')
-rw-r--r-- | internal/config/config.go | 4 | ||||
-rw-r--r-- | internal/config/defaults.go | 2 | ||||
-rw-r--r-- | internal/config/helpers.gen.go | 55 |
3 files changed, 58 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index f738ba797..8d410f6ac 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -198,7 +198,7 @@ type CacheConfiguration struct { AccountStatsMemRatio float64 `name:"account-stats-mem-ratio"` ApplicationMemRatio float64 `name:"application-mem-ratio"` BlockMemRatio float64 `name:"block-mem-ratio"` - BlockIDsMemRatio float64 `name:"block-mem-ratio"` + BlockIDsMemRatio float64 `name:"block-ids-mem-ratio"` BoostOfIDsMemRatio float64 `name:"boost-of-ids-mem-ratio"` ClientMemRatio float64 `name:"client-mem-ratio"` EmojiMemRatio float64 `name:"emoji-mem-ratio"` @@ -233,6 +233,8 @@ type CacheConfiguration struct { TokenMemRatio float64 `name:"token-mem-ratio"` TombstoneMemRatio float64 `name:"tombstone-mem-ratio"` UserMemRatio float64 `name:"user-mem-ratio"` + UserMuteMemRatio float64 `name:"user-mute-mem-ratio"` + UserMuteIDsMemRatio float64 `name:"user-mute-ids-mem-ratio"` WebfingerMemRatio float64 `name:"webfinger-mem-ratio"` VisibilityMemRatio float64 `name:"visibility-mem-ratio"` } diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 3410dc5e4..8a76cc21a 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -197,6 +197,8 @@ var Defaults = Configuration{ TokenMemRatio: 0.75, TombstoneMemRatio: 0.5, UserMemRatio: 0.25, + UserMuteMemRatio: 2, + UserMuteIDsMemRatio: 3, WebfingerMemRatio: 0.1, VisibilityMemRatio: 2, }, diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 2f37cbacb..edfe96e57 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -2,7 +2,7 @@ // GoToSocial // Copyright (C) GoToSocial Authors admin@gotosocial.org // SPDX-License-Identifier: AGPL-3.0-or-later -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or @@ -2917,7 +2917,7 @@ func (st *ConfigState) SetCacheBlockIDsMemRatio(v float64) { } // CacheBlockIDsMemRatioFlag returns the flag name for the 'Cache.BlockIDsMemRatio' field -func CacheBlockIDsMemRatioFlag() string { return "cache-block-mem-ratio" } +func CacheBlockIDsMemRatioFlag() string { return "cache-block-ids-mem-ratio" } // GetCacheBlockIDsMemRatio safely fetches the value for global configuration 'Cache.BlockIDsMemRatio' field func GetCacheBlockIDsMemRatio() float64 { return global.GetCacheBlockIDsMemRatio() } @@ -3775,6 +3775,56 @@ func GetCacheUserMemRatio() float64 { return global.GetCacheUserMemRatio() } // SetCacheUserMemRatio safely sets the value for global configuration 'Cache.UserMemRatio' field func SetCacheUserMemRatio(v float64) { global.SetCacheUserMemRatio(v) } +// GetCacheUserMuteMemRatio safely fetches the Configuration value for state's 'Cache.UserMuteMemRatio' field +func (st *ConfigState) GetCacheUserMuteMemRatio() (v float64) { + st.mutex.RLock() + v = st.config.Cache.UserMuteMemRatio + st.mutex.RUnlock() + return +} + +// SetCacheUserMuteMemRatio safely sets the Configuration value for state's 'Cache.UserMuteMemRatio' field +func (st *ConfigState) SetCacheUserMuteMemRatio(v float64) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.Cache.UserMuteMemRatio = v + st.reloadToViper() +} + +// CacheUserMuteMemRatioFlag returns the flag name for the 'Cache.UserMuteMemRatio' field +func CacheUserMuteMemRatioFlag() string { return "cache-user-mute-mem-ratio" } + +// GetCacheUserMuteMemRatio safely fetches the value for global configuration 'Cache.UserMuteMemRatio' field +func GetCacheUserMuteMemRatio() float64 { return global.GetCacheUserMuteMemRatio() } + +// SetCacheUserMuteMemRatio safely sets the value for global configuration 'Cache.UserMuteMemRatio' field +func SetCacheUserMuteMemRatio(v float64) { global.SetCacheUserMuteMemRatio(v) } + +// GetCacheUserMuteIDsMemRatio safely fetches the Configuration value for state's 'Cache.UserMuteIDsMemRatio' field +func (st *ConfigState) GetCacheUserMuteIDsMemRatio() (v float64) { + st.mutex.RLock() + v = st.config.Cache.UserMuteIDsMemRatio + st.mutex.RUnlock() + return +} + +// SetCacheUserMuteIDsMemRatio safely sets the Configuration value for state's 'Cache.UserMuteIDsMemRatio' field +func (st *ConfigState) SetCacheUserMuteIDsMemRatio(v float64) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.Cache.UserMuteIDsMemRatio = v + st.reloadToViper() +} + +// CacheUserMuteIDsMemRatioFlag returns the flag name for the 'Cache.UserMuteIDsMemRatio' field +func CacheUserMuteIDsMemRatioFlag() string { return "cache-user-mute-ids-mem-ratio" } + +// GetCacheUserMuteIDsMemRatio safely fetches the value for global configuration 'Cache.UserMuteIDsMemRatio' field +func GetCacheUserMuteIDsMemRatio() float64 { return global.GetCacheUserMuteIDsMemRatio() } + +// SetCacheUserMuteIDsMemRatio safely sets the value for global configuration 'Cache.UserMuteIDsMemRatio' field +func SetCacheUserMuteIDsMemRatio(v float64) { global.SetCacheUserMuteIDsMemRatio(v) } + // GetCacheWebfingerMemRatio safely fetches the Configuration value for state's 'Cache.WebfingerMemRatio' field func (st *ConfigState) GetCacheWebfingerMemRatio() (v float64) { st.mutex.RLock() @@ -4024,3 +4074,4 @@ func GetRequestIDHeader() string { return global.GetRequestIDHeader() } // SetRequestIDHeader safely sets the value for global configuration 'RequestIDHeader' field func SetRequestIDHeader(v string) { global.SetRequestIDHeader(v) } + |