Skip to content

Commit

Permalink
Merge pull request JMPerez#2 from neildevas/feature/playback-socket-e…
Browse files Browse the repository at this point in the history
…vents

Feature/playback socket events
  • Loading branch information
neildevas committed Sep 24, 2018
2 parents d44b508 + a070a35 commit d0cf878
Show file tree
Hide file tree
Showing 21 changed files with 309 additions and 723 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
config/config.json
tsconfig.json
tsconfig.json
playground
36 changes: 0 additions & 36 deletions playground/errorHandling.js

This file was deleted.

44 changes: 0 additions & 44 deletions playground/middleware.js

This file was deleted.

50 changes: 0 additions & 50 deletions playground/routing.js

This file was deleted.

76 changes: 28 additions & 48 deletions server/controllers/Party.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ async function createParty({ partyName, user }) {
name: partyName,
leader_id: user.id,
users: [user],
})
});
await party.save();

return party;
} catch (err) {
throw err;
Expand All @@ -93,9 +94,6 @@ async function getParty({ party_id }) {
}
try {
const party = await Party.findById(party_id);
if (!party) {
throw Boom.notFound(`No party was found for id ${party_id}`);
}
return party;
} catch (err) {
throw err;
Expand Down Expand Up @@ -130,49 +128,6 @@ async function addUser({ party_id, user }) {
}
}

// async function canInvite({ sender_id, receiver_id, party_id }) {
// if (!sender_id) {
// throw Boom.badRequest('No sender id was passed in');
// }
// if (!receiver_id) {
// throw Boom.badRequest('No receiver id was passed in');
// }
// if (!party_id) {
// throw Boom.badRequest('No party id was passed in');
// }
// return UserController.getUser({ user_id: sender_id })
// .then(sender => {
// if (!sender) {
// return Promise.reject(`No user was found with id ${sender_id}`);
// }
// // make sure to change this
// return userIsInParty({ party_id, user_id: sender_id })
// .then(party => {
// if (!party) {
// return Promise.reject(`Sender ${sender_id} is not in party ${party._id}`)
// }
// return UserController.getUser({ user_id: receiver_id })
// .then(receiver => {
// if (!receiver) {
// return Promise.reject(`No user was found with id ${receiver}`);
// }
// return party;
// })
// })
// })
// .catch(err => Promise.reject(err));
// // }
// async function canInvite({ sender, party_id }) {
// let canInvite = false;
// if (!sender_id) {
// throw Boom.badRequest('No sender id was passed in');
// }
// if (!party_id) {
// throw Boom.badRequest('No party id was passed in');
// }

// }

async function removeUser({ party_id, user }) {
if (!party_id) {
throw Boom.badRequest('No party id was passed in');
Expand All @@ -192,7 +147,32 @@ async function removeUser({ party_id, user }) {
} catch (err) {
throw err;
}
}
};

async function canInvite({ user, party_id }) {
if (!party_id) {
throw Boom.badRequest('No party id was passed in');
}
if (!user) {
throw Boom.badRequest('No user was passed in');
}
try {
const isInParty = await userIsInParty({ user, party_id });
if (isInParty) {
const party = await getParty({ party_id });
if (!party.is_locked) {
return true;
}
if (party.is_locked && party.leader_id !== user.id) {
return false;
}
}
return false;
} catch (err) {
throw err;
}
};


module.exports = {
createParty,
Expand Down
85 changes: 0 additions & 85 deletions server/controllers/PlayQueue.js

This file was deleted.

Loading

0 comments on commit d0cf878

Please sign in to comment.