|
@@ -120,14 +120,18 @@ async function enqueue(group, method, job) {
|
|
|
async function getProjectUsersIds(projectId) {
|
|
async function getProjectUsersIds(projectId) {
|
|
|
// get list of all user ids with access to project. project owner
|
|
// get list of all user ids with access to project. project owner
|
|
|
// will always be the first entry in the list.
|
|
// will always be the first entry in the list.
|
|
|
- const projectUserIds = await CollaboratorsGetter.getInvitedMemberIds(
|
|
|
|
|
- projectId
|
|
|
|
|
- )
|
|
|
|
|
- // filter list to only return users with dropbox linked
|
|
|
|
|
- // skip the first user id, which is always returned
|
|
|
|
|
|
|
+ const [
|
|
|
|
|
+ ownerUserId,
|
|
|
|
|
+ ...invitedUserIds
|
|
|
|
|
+ ] = await CollaboratorsGetter.getInvitedMemberIds(projectId)
|
|
|
|
|
+ // if there are no invited users, always return the owner
|
|
|
|
|
+ if (!invitedUserIds.length) {
|
|
|
|
|
+ return [ownerUserId]
|
|
|
|
|
+ }
|
|
|
|
|
+ // filter invited users to only return those with dropbox linked
|
|
|
const dropboxUsers = await UserGetter.getUsers(
|
|
const dropboxUsers = await UserGetter.getUsers(
|
|
|
{
|
|
{
|
|
|
- _id: { $in: projectUserIds.slice(1).map(id => ObjectId(id)) },
|
|
|
|
|
|
|
+ _id: { $in: invitedUserIds.map(id => ObjectId(id)) },
|
|
|
'dropbox.access_token.uid': { $ne: null }
|
|
'dropbox.access_token.uid': { $ne: null }
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
@@ -135,7 +139,7 @@ async function getProjectUsersIds(projectId) {
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
const dropboxUserIds = dropboxUsers.map(user => user._id)
|
|
const dropboxUserIds = dropboxUsers.map(user => user._id)
|
|
|
- return [projectUserIds[0], ...dropboxUserIds]
|
|
|
|
|
|
|
+ return [ownerUserId, ...dropboxUserIds]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function moveEntity(options) {
|
|
async function moveEntity(options) {
|