Added limits to character strings, migration to remove image data urls from character pictures

This commit is contained in:
Stefan Zermatten
2021-08-10 10:44:24 +02:00
parent c0b031f2b5
commit c48cc20fb9
2 changed files with 37 additions and 12 deletions

View File

@@ -3,18 +3,18 @@ Characters = new Mongo.Collection("characters");
Schemas.Character = new SimpleSchema({
//strings
name: {type: String, defaultValue: "", trim: false, optional: true},
urlName: {type: String, defaultValue: "-", trim: false, optional: true},
alignment: {type: String, defaultValue: "", trim: false, optional: true},
gender: {type: String, defaultValue: "", trim: false, optional: true},
race: {type: String, defaultValue: "", trim: false, optional: true},
picture: {type: String, defaultValue: "", trim: true, optional: true},
description: {type: String, defaultValue: "", trim: false, optional: true},
personality: {type: String, defaultValue: "", trim: false, optional: true},
ideals: {type: String, defaultValue: "", trim: false, optional: true},
bonds: {type: String, defaultValue: "", trim: false, optional: true},
flaws: {type: String, defaultValue: "", trim: false, optional: true},
backstory: {type: String, defaultValue: "", trim: false, optional: true},
name: {type: String, defaultValue: "", trim: false, optional: true, max: 128},
urlName: {type: String, defaultValue: "-", trim: false, optional: true, max: 128},
alignment: {type: String, defaultValue: "", trim: false, optional: true, max: 64},
gender: {type: String, defaultValue: "", trim: false, optional: true, max: 64},
race: {type: String, defaultValue: "", trim: false, optional: true, max: 64},
picture: {type: String, defaultValue: "", trim: true, optional: true, max: 256},
description: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
personality: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
ideals: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
bonds: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
flaws: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
backstory: {type: String, defaultValue: "", trim: false, optional: true, max: 5000},
//attributes
//ability scores

View File

@@ -54,3 +54,28 @@ Migrations.add({
return;
},
});
Migrations.add({
version: 3,
name: "Removes data images from character pictures",
up: function() {
//update characters
Characters.find({}).forEach(function(char){
if (char.tempHP) return;
Characters.update(char._id, {$set: {
"tempHP.adjustment": 0,
"tempHP.reset": "longRest",
}});
});
Characters.update({
picture: /^data/
}, {
$set: {picture: ''}
}, {
multi: true
});
},
down: function(){
return;
},
});