summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/models/user.js3
-rw-r--r--lib/realtime.js12
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/models/user.js b/lib/models/user.js
index 4c823355..62ed5cc7 100644
--- a/lib/models/user.js
+++ b/lib/models/user.js
@@ -66,6 +66,9 @@ module.exports = function (sequelize, DataTypes) {
})
},
getProfile: function (user) {
+ if (!user) {
+ return null
+ }
return user.profile ? User.parseProfile(user.profile) : (user.email ? User.parseProfileByEmail(user.email) : null)
},
parseProfile: function (profile) {
diff --git a/lib/realtime.js b/lib/realtime.js
index 070bde2d..f6c62d4e 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -486,11 +486,13 @@ function startConnection (socket) {
for (var i = 0; i < note.authors.length; i++) {
var author = note.authors[i]
var profile = models.User.getProfile(author.user)
- authors[author.userId] = {
- userid: author.userId,
- color: author.color,
- photo: profile.photo,
- name: profile.name
+ if (profile) {
+ authors[author.userId] = {
+ userid: author.userId,
+ color: author.color,
+ photo: profile.photo,
+ name: profile.name
+ }
}
}