mirror of
https://github.com/Sheldan/OnePlusBot.git
synced 2026-03-29 16:16:09 +00:00
[OPB-38] fixing json validation
This commit is contained in:
@@ -66,6 +66,7 @@ public class ImportFAQ extends AbstractConditionableCommand {
|
|||||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||||
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
|
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
|
||||||
faqServiceBean.createOrUpdateFAQCommands(commands, server);
|
faqServiceBean.createOrUpdateFAQCommands(commands, server);
|
||||||
|
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
|
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
|
||||||
@@ -73,8 +74,8 @@ public class ImportFAQ extends AbstractConditionableCommand {
|
|||||||
.map(ValidationException::getMessage)
|
.map(ValidationException::getMessage)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
|
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
|
||||||
|
return CompletableFuture.completedFuture(CommandResult.fromError("Incorrect faq config."));
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("IO Exception when loading input file.", e);
|
log.error("IO Exception when loading input file.", e);
|
||||||
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);
|
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);
|
||||||
|
|||||||
@@ -3,143 +3,124 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"maxItems": 30,
|
"maxItems": 30,
|
||||||
"items": [
|
"items": {
|
||||||
{
|
"type": "object",
|
||||||
"type": "object",
|
"properties": {
|
||||||
"properties": {
|
"faqCommandName": {
|
||||||
"faqCommandName": {
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"maxLength": 30,
|
||||||
|
"pattern": "\\w*"
|
||||||
|
},
|
||||||
|
"global": {
|
||||||
|
"default": false,
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"aliases": {
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"maxItems": 20,
|
||||||
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"maxLength": 30,
|
"maxLength": 30,
|
||||||
"pattern": "\\w*"
|
"pattern": "\\w*"
|
||||||
},
|
}
|
||||||
"global": {
|
},
|
||||||
"default": false,
|
"responses": {
|
||||||
"type": "boolean"
|
"type": "array",
|
||||||
},
|
"minItems": 1,
|
||||||
"aliases": {
|
"maxItems": 255,
|
||||||
"type": "array",
|
"items": {
|
||||||
"minItems": 1,
|
"type": "object",
|
||||||
"maxItems": 20,
|
"properties": {
|
||||||
"items": {
|
"channelGroupName": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"maxLength": 30,
|
"maxLength": 20,
|
||||||
"pattern": "\\w*"
|
"pattern": "\\w*"
|
||||||
}
|
},
|
||||||
},
|
"messages": {
|
||||||
"responses": {
|
"type": "array",
|
||||||
"type": "array",
|
"minItems": 1,
|
||||||
"minItems": 1,
|
"maxItems": 3,
|
||||||
"maxItems": 255,
|
"items": {
|
||||||
"items": {
|
"type": "object",
|
||||||
"type": "object",
|
"properties": {
|
||||||
"properties": {
|
"position": {
|
||||||
"channelGroupName": {
|
"type": "number",
|
||||||
"type": "string",
|
"minimum": 0,
|
||||||
"minLength": 1,
|
"maximum": 2
|
||||||
"maxLength": 20,
|
},
|
||||||
"pattern": "\\w*"
|
"additionalMessage": {
|
||||||
},
|
"type": "string",
|
||||||
"messages": {
|
"minLength": 1,
|
||||||
"type": "array",
|
"maxLength": 2000
|
||||||
"minItems": 1,
|
},
|
||||||
"maxItems": 3,
|
"embed": {
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"position": {
|
"description": {
|
||||||
"type": "number",
|
|
||||||
"minimum": 0,
|
|
||||||
"maximum": 2
|
|
||||||
},
|
|
||||||
"additionalMessage": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
"maxLength": 2000
|
"maxLength": 2000
|
||||||
},
|
},
|
||||||
"embed": {
|
"imageUrl": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1,
|
||||||
|
"maxLength": 2000,
|
||||||
|
"pattern": "\\s*https?:\/\/\\S+"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"description": {
|
"red": {
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"minLength": 1,
|
"minimum": 0,
|
||||||
"maxLength": 2000
|
"default": 0,
|
||||||
|
"maximum": 255
|
||||||
},
|
},
|
||||||
"imageUrl": {
|
"green": {
|
||||||
"type": "string",
|
"type": "integer",
|
||||||
"minLength": 1,
|
"minimum": 0,
|
||||||
"maxLength": 2000,
|
"default": 0,
|
||||||
"pattern": "\\s*https?:\/\/\\S+"
|
"maximum": 255
|
||||||
},
|
},
|
||||||
"color": {
|
"blue": {
|
||||||
"type": "object",
|
"type": "integer",
|
||||||
"properties": {
|
"minimum": 0,
|
||||||
"red": {
|
"default": 0,
|
||||||
"type": "integer",
|
"maximum": 255
|
||||||
"minimum": 0,
|
}
|
||||||
"default": 0,
|
},
|
||||||
"maximum": 255
|
"required": [
|
||||||
},
|
"red",
|
||||||
"green": {
|
"green",
|
||||||
"type": "integer",
|
"blue"
|
||||||
"minimum": 0,
|
]
|
||||||
"default": 0,
|
},
|
||||||
"maximum": 255
|
"author": {
|
||||||
},
|
"type": "object",
|
||||||
"blue": {
|
"properties": {
|
||||||
"type": "integer",
|
"userId": {
|
||||||
"minimum": 0,
|
"minimum": 1,
|
||||||
"default": 0,
|
"maximum": 18446744073709551615,
|
||||||
"maximum": 255
|
"type": "integer"
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"red",
|
|
||||||
"green",
|
|
||||||
"blue"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"author": {
|
"useBot": {
|
||||||
"type": "object",
|
"type": "boolean"
|
||||||
"properties": {
|
|
||||||
"userId": {
|
|
||||||
"minimum": 1,
|
|
||||||
"maximum": 18446744073709551615,
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"useBot": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"required": [
|
|
||||||
"userId"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"required": [
|
|
||||||
"useBot"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"required": [
|
"required": [
|
||||||
"description",
|
"userId"
|
||||||
"author"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"required": [
|
"required": [
|
||||||
"imageUrl",
|
"useBot"
|
||||||
"author"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -149,41 +130,56 @@
|
|||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"required": [
|
"required": [
|
||||||
"additionalMessage",
|
"description",
|
||||||
"position"
|
"author"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"required": [
|
"required": [
|
||||||
"embed",
|
"imageUrl",
|
||||||
"position"
|
"author"
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"required": [
|
|
||||||
"additionalMessage",
|
|
||||||
"embed",
|
|
||||||
"position"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"additionalMessage",
|
||||||
|
"position"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"embed",
|
||||||
|
"position"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"required": [
|
||||||
|
"additionalMessage",
|
||||||
|
"embed",
|
||||||
|
"position"
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"additionalProperties": false,
|
},
|
||||||
"required": [
|
"additionalProperties": false,
|
||||||
"channelGroupName",
|
"required": [
|
||||||
"messages"
|
"channelGroupName",
|
||||||
]
|
"messages"
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"additionalProperties": false,
|
},
|
||||||
"required": [
|
"additionalProperties": false,
|
||||||
"faqCommandName",
|
"required": [
|
||||||
"responses"
|
"faqCommandName",
|
||||||
]
|
"responses"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user