v3: fix crashes when group or leader cannot be populated and fixes challenges migration for tavern challenges

This commit is contained in:
Matteo Pagliazzi
2016-05-07 17:35:13 +02:00
parent 4e3d4c8831
commit 77d2d943ae
3 changed files with 22 additions and 9 deletions

View File

@@ -112,6 +112,15 @@ function processChallenges (afterId) {
if (!oldChallenge.group) throw new Error('challenge.group is required');
if (!oldChallenge.leader) throw new Error('challenge.leader is required');
if (oldChallenge.leader === '9') {
oldChallenge.leader = '00000000-0000-4000-9000-000000000000';
}
if (oldChallenge.group === 'habitrpg') {
oldChallenge.group = '00000000-0000-4000-A000-000000000000';
}
delete oldChallenge.id;
var newChallenge = new NewChallenge(oldChallenge);