Page MenuHomePhabricator

Integrate Community Configuration into AutoModerator
Open, LowPublic

Description

We have a number of configuration options for AutoModerator which can currently be customised only by editing MediaWiki:AutoModeratorConfig.json locally. We would like to integrate Community Configuration to make the process of configuration AutoModerator more seamless and user friendly.

Designs/copy

Initial explorations in the Figma files linked in T349238. Note that we're moving message strings such as edit summary out of config.

Community Config Technical Details

Note: Null data types are not supported in CC 2.0. For now, we should just use empty strings in our schema in places where we would otherwise use null and update code accordingly.

Step 1:
Download the extension and enable it per documentation here.

Step 2:
Update AutoModerator's extension.json to include the community configuration provider.

	"attributes": {
		"CommunityConfiguration": {
			"Providers": {
				"MyProvider": {
					"store": {
						"type": "wikipage",
						"args": [
							"MediaWiki:AutoModeratorConfig.json"
						]
					},
					"validator": {
						"type": "jsonschema",
						"args": [
							"AutoModerator\\Config\\Validation\\AutoModeratorConfigSchema"
						]
					},
					"type": "mw-config"
				}
			}
		}
	},

Step 3: Create an AutoModeratorConfigSchema class in the AutoModerator extension that will be referenced in your provider config from step 1:

class AutoModeratorConfigSchema extends JsonSchema
{
	public const AutoModeratorEnableRevisionCheck = [
		self::TYPE => self::TYPE_BOOLEAN
	];

	public const AutoModeratorFalsePositivePageTitle = [
		self::TYPE => self::TYPE_STRING
	];

	public const AutoModeratorSkipUserGroups = [
		self::TYPE => self::TYPE_ARRAY
	];

	public const AutoModeratorUseEditFlagMinor = [
		self::TYPE => self::TYPE_BOOLEAN
	];

	public const AutoModeratorRevertTalkPageMessageEnabled = [
		self::TYPE => self::TYPE_BOOLEAN
	];

	public const AutoModeratorCautionLevel = [
		self::TYPE => self::TYPE_STRING,
		self::ENUM => ['Very cautious', 'Cautious', 'Somewhat cautious', 'Less cautious']
	];
}

You can then validate the configuration on wiki and ensure the types are being validated correctly.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Kgraessle updated the task description. (Show Details)
jsn.sherman updated the task description. (Show Details)