Fix requests for deleted users
When users are requested from the authorship which no longer exist, they shouldn't cause a 500. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
4229084c62
commit
e31d204d74
2 changed files with 10 additions and 5 deletions
|
@ -66,6 +66,9 @@ module.exports = function (sequelize, DataTypes) {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getProfile: function (user) {
|
getProfile: function (user) {
|
||||||
|
if (!user) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
return user.profile ? User.parseProfile(user.profile) : (user.email ? User.parseProfileByEmail(user.email) : null)
|
return user.profile ? User.parseProfile(user.profile) : (user.email ? User.parseProfileByEmail(user.email) : null)
|
||||||
},
|
},
|
||||||
parseProfile: function (profile) {
|
parseProfile: function (profile) {
|
||||||
|
|
|
@ -486,11 +486,13 @@ function startConnection (socket) {
|
||||||
for (var i = 0; i < note.authors.length; i++) {
|
for (var i = 0; i < note.authors.length; i++) {
|
||||||
var author = note.authors[i]
|
var author = note.authors[i]
|
||||||
var profile = models.User.getProfile(author.user)
|
var profile = models.User.getProfile(author.user)
|
||||||
authors[author.userId] = {
|
if (profile) {
|
||||||
userid: author.userId,
|
authors[author.userId] = {
|
||||||
color: author.color,
|
userid: author.userId,
|
||||||
photo: profile.photo,
|
color: author.color,
|
||||||
name: profile.name
|
photo: profile.photo,
|
||||||
|
name: profile.name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue