mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Add instance-stats-randomize
config option (#3718)
* [feature] Add `instance-stats-randomize` config option * don't use cache (overkill)
This commit is contained in:
@ -21,7 +21,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -58,6 +60,12 @@ func (m *Module) InstanceInformationGETHandlerV1(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
// Replace actual stats with cached randomized ones.
|
||||
instance.Stats["user_count"] = util.Ptr(int(instance.RandomStats.TotalUsers))
|
||||
instance.Stats["status_count"] = util.Ptr(int(instance.RandomStats.Statuses))
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
}
|
||||
|
||||
@ -93,5 +101,10 @@ func (m *Module) InstanceInformationGETHandlerV2(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
// Replace actual stats with cached randomized ones.
|
||||
instance.Usage.Users.ActiveMonth = int(instance.RandomStats.MonthlyActiveUsers)
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
}
|
||||
|
Reference in New Issue
Block a user