){returnres.status(400).send("The server cannot accept your request as your body is missing fields or is malformed. Ensure fields aren't too long and that they don't contain illegal characters.");}
constseries=awaitAnime.findOne({$or:[{id:req.params.id.toLowerCase()},{numericalId:req.params.id}]});//TODO make sure all ID calls are lowercased
constseries=awaitAnime.findOne(/*{$or: [*/{id:req.params.id.toLowerCase()}/*, {numericalId: req.params.id}]}*/);//TODO make sure all ID calls are lowercased
if(req.body.updateAuthor===true&&series.synopsis.by!==req.authenticatedUser.id){series.synopsis.by=req.authenticatedUser.id;}// TODO doc this extraneous body item
pushEdit("Updated synopsis",req,series);
series.markModified('synopsis.synopsis');
returnseries.save()
.then(()=>res.send("Synopsis updated."))
.catch(()=>res.status(500).send("There was an error trying to update your synopsis. Please try again."));
}
catch{returnres.status(500).send("There was an error trying to update your synopsis. Please try again.");}
series.meta.edits.push({
user:req.authenticatedUser.id,
timestamp:newDate().getTime(),
action:"Updated synopsis"
});
series.markModified('synopsis.synopsis');
series.markModified('meta.edits');
returnseries.save()
.then(()=>res.send("Synopsis updated."))
.catch(()=>res.status(500).send("There was an error trying to update your synopsis. Please try again."));
if(!req.body.name){returnres.status(400).send("You did not provide a new name in your body.");}
if(!req.body.name.match(/^[\w_\-!?.:; ]+$/gm)||req.body.name.length>150){returnres.status(400).send("Your new name is too long or contains illegal characters.");}
try{
series.name=req.body.name.trim();
pushEdit("Updated name",req,series);
returnseries.save()
.then(()=>res.send("Name updated."))
.catch(()=>res.status(500).send("There was an error trying to update your name. Please try again."));
}catch{returnres.status(500).send("There was an error trying to update your name. Please try again.");}