mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Send an empty string for every nameless user
This commit is contained in:
parent
0a98eb436b
commit
cb12e1c6f6
2 changed files with 44 additions and 26 deletions
|
@ -145,26 +145,24 @@ module.exports = WebsocketController =
|
||||||
cursorData.id = client.id
|
cursorData.id = client.id
|
||||||
cursorData.user_id = user_id if user_id?
|
cursorData.user_id = user_id if user_id?
|
||||||
cursorData.email = email if email?
|
cursorData.email = email if email?
|
||||||
if first_name or last_name
|
cursorData.name = if first_name && last_name
|
||||||
cursorData.name = if first_name && last_name
|
"#{first_name} #{last_name}"
|
||||||
"#{first_name} #{last_name}"
|
else if first_name
|
||||||
else if first_name
|
first_name
|
||||||
first_name
|
else if last_name
|
||||||
else if last_name
|
last_name
|
||||||
last_name
|
|
||||||
ConnectedUsersManager.updateUserPosition(project_id, client.id, {
|
|
||||||
first_name: first_name,
|
|
||||||
last_name: last_name,
|
|
||||||
email: email,
|
|
||||||
_id: user_id
|
|
||||||
}, {
|
|
||||||
row: cursorData.row,
|
|
||||||
column: cursorData.column,
|
|
||||||
doc_id: cursorData.doc_id
|
|
||||||
}, callback)
|
|
||||||
else
|
else
|
||||||
cursorData.name = "Anonymous"
|
""
|
||||||
callback()
|
ConnectedUsersManager.updateUserPosition(project_id, client.id, {
|
||||||
|
first_name: first_name,
|
||||||
|
last_name: last_name,
|
||||||
|
email: email,
|
||||||
|
_id: user_id
|
||||||
|
}, {
|
||||||
|
row: cursorData.row,
|
||||||
|
column: cursorData.column,
|
||||||
|
doc_id: cursorData.doc_id
|
||||||
|
}, callback)
|
||||||
WebsocketLoadBalancer.emitToRoom(project_id, "clientTracking.clientUpdated", cursorData)
|
WebsocketLoadBalancer.emitToRoom(project_id, "clientTracking.clientUpdated", cursorData)
|
||||||
|
|
||||||
getConnectedUsers: (client, callback = (error, users) ->) ->
|
getConnectedUsers: (client, callback = (error, users) ->) ->
|
||||||
|
|
|
@ -426,7 +426,7 @@ describe 'WebsocketController', ->
|
||||||
doc_id: @doc_id
|
doc_id: @doc_id
|
||||||
}).should.equal true
|
}).should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it "should increment the update-client-position metric at 0.1 frequency", ->
|
it "should increment the update-client-position metric at 0.1 frequency", ->
|
||||||
@metrics.inc.calledWith("editor.update-client-position", 0.1).should.equal true
|
@metrics.inc.calledWith("editor.update-client-position", 0.1).should.equal true
|
||||||
|
|
||||||
|
@ -509,6 +509,30 @@ describe 'WebsocketController', ->
|
||||||
|
|
||||||
it "should increment the update-client-position metric at 0.1 frequency", ->
|
it "should increment the update-client-position metric at 0.1 frequency", ->
|
||||||
@metrics.inc.calledWith("editor.update-client-position", 0.1).should.equal true
|
@metrics.inc.calledWith("editor.update-client-position", 0.1).should.equal true
|
||||||
|
describe "with a logged in user who has no names set", ->
|
||||||
|
beforeEach ->
|
||||||
|
@clientParams = {
|
||||||
|
project_id: @project_id
|
||||||
|
first_name: undefined
|
||||||
|
last_name: undefined
|
||||||
|
email: @email = "joe@example.com"
|
||||||
|
user_id: @user_id = "user-id-123"
|
||||||
|
}
|
||||||
|
@client.get = (param, callback) => callback null, @clientParams[param]
|
||||||
|
@WebsocketController.updateClientPosition @client, @update
|
||||||
|
|
||||||
|
it "should send the update to the project name with no name", ->
|
||||||
|
@WebsocketLoadBalancer.emitToRoom
|
||||||
|
.calledWith(@project_id, "clientTracking.clientUpdated", {
|
||||||
|
doc_id: @doc_id,
|
||||||
|
id: @client.id,
|
||||||
|
user_id: @user_id,
|
||||||
|
name: "",
|
||||||
|
row: @row,
|
||||||
|
column: @column,
|
||||||
|
email: @email
|
||||||
|
})
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
|
|
||||||
describe "with an anonymous user", ->
|
describe "with an anonymous user", ->
|
||||||
|
@ -519,20 +543,16 @@ describe 'WebsocketController', ->
|
||||||
@client.get = (param, callback) => callback null, @clientParams[param]
|
@client.get = (param, callback) => callback null, @clientParams[param]
|
||||||
@WebsocketController.updateClientPosition @client, @update
|
@WebsocketController.updateClientPosition @client, @update
|
||||||
|
|
||||||
it "should send the update to the project room with an anonymous name", ->
|
it "should send the update to the project room with no name", ->
|
||||||
@WebsocketLoadBalancer.emitToRoom
|
@WebsocketLoadBalancer.emitToRoom
|
||||||
.calledWith(@project_id, "clientTracking.clientUpdated", {
|
.calledWith(@project_id, "clientTracking.clientUpdated", {
|
||||||
doc_id: @doc_id,
|
doc_id: @doc_id,
|
||||||
id: @client.id
|
id: @client.id
|
||||||
name: "Anonymous"
|
name: ""
|
||||||
row: @row
|
row: @row
|
||||||
column: @column
|
column: @column
|
||||||
})
|
})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should not send cursor data to the connected user manager", (done)->
|
|
||||||
@ConnectedUsersManager.updateUserPosition.called.should.equal false
|
|
||||||
done()
|
|
||||||
|
|
||||||
describe "applyOtUpdate", ->
|
describe "applyOtUpdate", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
|
Loading…
Reference in a new issue