mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[feature] Change instance-stats-randomize
to instance-stats-mode
with multiple options; implement nodeinfo 2.1 (#3734)
* [feature] Change `instance-stats-randomize` to `instance-stats-mode` with multiple options; implement nodeinfo 2.1 * swaggalaggadingdong
This commit is contained in:
@ -60,10 +60,21 @@ func (m *Module) InstanceInformationGETHandlerV1(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
switch config.GetInstanceStatsMode() {
|
||||
|
||||
case config.InstanceStatsModeBaffle:
|
||||
// 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))
|
||||
|
||||
case config.InstanceStatsModeZero:
|
||||
// Replace actual stats with zero.
|
||||
instance.Stats["user_count"] = new(int)
|
||||
instance.Stats["status_count"] = new(int)
|
||||
|
||||
default:
|
||||
// serve or default.
|
||||
// Leave stats alone.
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
@ -101,9 +112,19 @@ func (m *Module) InstanceInformationGETHandlerV2(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if config.GetInstanceStatsRandomize() {
|
||||
switch config.GetInstanceStatsMode() {
|
||||
|
||||
case config.InstanceStatsModeBaffle:
|
||||
// Replace actual stats with cached randomized ones.
|
||||
instance.Usage.Users.ActiveMonth = int(instance.RandomStats.MonthlyActiveUsers)
|
||||
|
||||
case config.InstanceStatsModeZero:
|
||||
// Replace actual stats with zero.
|
||||
instance.Usage.Users.ActiveMonth = 0
|
||||
|
||||
default:
|
||||
// serve or default.
|
||||
// Leave stats alone.
|
||||
}
|
||||
|
||||
apiutil.JSON(c, http.StatusOK, instance)
|
||||
|
Reference in New Issue
Block a user