mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 12:02:26 -05: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:
		
					parent
					
						
							
								e1781ff52e
							
						
					
				
			
			
				commit
				
					
						07d2770995
					
				
			
		
					 18 changed files with 283 additions and 77 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue