mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
trying some fixes for server crashing
This commit is contained in:
@@ -175,6 +175,16 @@ score = function(taskId, direction, options) {
|
||||
times: 1
|
||||
};
|
||||
}
|
||||
if (_.isEmpty(model.get('_user'))) {
|
||||
console.log({
|
||||
taskId: taskId,
|
||||
direction: direction,
|
||||
options: options,
|
||||
user: model.get('_user'),
|
||||
error: 'non-user attempted to score'
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
taskPath = "_user.tasks." + taskId;
|
||||
_ref = [model.at(taskPath), model.get(taskPath)], task = _ref[0], taskObj = _ref[1];
|
||||
type = taskObj.type, value = taskObj.value;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
var scoring;
|
||||
var scoring, _;
|
||||
|
||||
scoring = require('../app/scoring');
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
module.exports = function(expressApp, root, derby) {
|
||||
var deprecatedMessage, staticPages;
|
||||
staticPages = derby.createStatic(root);
|
||||
@@ -34,7 +36,7 @@ module.exports = function(expressApp, root, derby) {
|
||||
model.session.userId = uid;
|
||||
return model.fetch("users." + uid, function(err, user) {
|
||||
var delta, result;
|
||||
if (err || !user.get()) {
|
||||
if (err || _.isEmpty(user.get())) {
|
||||
err || (err = 'No user with that ID');
|
||||
return res.send(500, err);
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@ updateStats = (stats) ->
|
||||
# {direction} 'up' or 'down'
|
||||
# {options} will usually be passed in via cron or tests, safe to ignore this param
|
||||
score = (taskId, direction, options={cron:false, times:1}) ->
|
||||
# FIXME seem to be finding issues here
|
||||
if _.isEmpty(model.get('_user'))
|
||||
console.log {taskId:taskId, direction:direction, options:options, user:model.get('_user'), error: 'non-user attempted to score'}
|
||||
return 0
|
||||
taskPath = "_user.tasks.#{taskId}"
|
||||
[task, taskObj] = [model.at(taskPath), model.get(taskPath)]
|
||||
{type, value} = taskObj
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
scoring = require('../app/scoring')
|
||||
_ = require('lodash')
|
||||
|
||||
module.exports = (expressApp, root, derby) ->
|
||||
|
||||
@@ -29,7 +30,7 @@ module.exports = (expressApp, root, derby) ->
|
||||
model = req.getModel()
|
||||
model.session.userId = uid
|
||||
model.fetch "users.#{uid}", (err, user) ->
|
||||
if err || !user.get()
|
||||
if err || _.isEmpty(user.get())
|
||||
err ||= 'No user with that ID'
|
||||
return res.send(500, err)
|
||||
model.ref('_user', user)
|
||||
|
||||
Reference in New Issue
Block a user