mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add a getInvitedMemberIds
function
Limited to only members who were invited to the project, not users who have access via a token.
This commit is contained in:
parent
fc202439ab
commit
cf54989e6a
2 changed files with 19 additions and 1 deletions
|
@ -40,6 +40,11 @@ module.exports = CollaboratorsHandler =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
return callback null, members.map (m) -> m.id
|
return callback null, members.map (m) -> m.id
|
||||||
|
|
||||||
|
getInvitedMemberIds: (project_id, callback = (error, member_ids) ->) ->
|
||||||
|
CollaboratorsHandler.getMemberIdsWithPrivilegeLevels project_id, (error, members) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
return callback null, members.filter((m) -> m.source == Sources.INVITE).map((m) -> m.id)
|
||||||
|
|
||||||
USER_PROJECTION: {
|
USER_PROJECTION: {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
email: 1,
|
email: 1,
|
||||||
|
|
|
@ -62,7 +62,7 @@ describe "CollaboratorsHandler", ->
|
||||||
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
||||||
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels
|
||||||
.withArgs(@project_id)
|
.withArgs(@project_id)
|
||||||
.yields(null, [{id: "member-id-1"}, {id: "member-id-2"}])
|
.yields(null, [{id: "member-id-1", source: 'invite'}, {id: "member-id-2", source: 'token'}])
|
||||||
@CollaboratorHandler.getMemberIds @project_id, @callback
|
@CollaboratorHandler.getMemberIds @project_id, @callback
|
||||||
|
|
||||||
it "should return the ids", ->
|
it "should return the ids", ->
|
||||||
|
@ -70,6 +70,19 @@ describe "CollaboratorsHandler", ->
|
||||||
.calledWith(null, ["member-id-1", "member-id-2"])
|
.calledWith(null, ["member-id-1", "member-id-2"])
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
describe "getInvitedMemberIds", ->
|
||||||
|
beforeEach ->
|
||||||
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
||||||
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels
|
||||||
|
.withArgs(@project_id)
|
||||||
|
.yields(null, [{id: "member-id-1", source: 'invite'}, {id: "member-id-2", source: 'token'}])
|
||||||
|
@CollaboratorHandler.getInvitedMemberIds @project_id, @callback
|
||||||
|
|
||||||
|
it "should return the invited ids", ->
|
||||||
|
@callback
|
||||||
|
.calledWith(null, ["member-id-1"])
|
||||||
|
.should.equal true
|
||||||
|
|
||||||
describe "getMembersWithPrivilegeLevels", ->
|
describe "getMembersWithPrivilegeLevels", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
@CollaboratorHandler.getMemberIdsWithPrivilegeLevels = sinon.stub()
|
||||||
|
|
Loading…
Reference in a new issue