mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 11:31:55 +02:00
Handle deleted users in comments gracefully
This commit is contained in:
@@ -30,6 +30,8 @@ module.exports = UserController =
|
||||
res.send JSON.stringify(info)
|
||||
|
||||
formatPersonalInfo: (user, callback = (error, info) ->) ->
|
||||
if !user?
|
||||
return {}
|
||||
formatted_user = { id: user._id.toString() }
|
||||
for key in ["first_name", "last_name", "email", "signUpDate", "role", "institution"]
|
||||
if user[key]?
|
||||
|
||||
@@ -373,7 +373,9 @@ define [
|
||||
return comment
|
||||
|
||||
formatUser = (user) ->
|
||||
if !user?
|
||||
id = user?._id or user?.id
|
||||
|
||||
if !id?
|
||||
return {
|
||||
email: null
|
||||
name: "Anonymous"
|
||||
@@ -381,13 +383,13 @@ define [
|
||||
hue: ColorManager.ANONYMOUS_HUE
|
||||
avatar_text: "A"
|
||||
}
|
||||
|
||||
id = user._id or user.id
|
||||
if id == window.user_id
|
||||
name = "You"
|
||||
isSelf = true
|
||||
else
|
||||
name = "#{user.first_name} #{user.last_name}"
|
||||
name = [user.first_name, user.last_name].filter((n) -> n?).join(" ")
|
||||
if name == ""
|
||||
name = "Unknown"
|
||||
isSelf = false
|
||||
return {
|
||||
id: id
|
||||
|
||||
Reference in New Issue
Block a user