Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const paidAgreement = async (body, userId) => {
- return postModel.findOne({
- include: {
- model: agreementModel,
- where: {
- id: body.agreementId
- }
- }
- }).then(post => {
- if (isPostCreator(post, userId)) {
- if (post.agreements[0].status === enums.agreementStatus.done) {
- return agreementModel.update({
- status: enums.agreementStatus.paid
- }, {
- where: {
- id: post.agreements[0].id
- },
- returning: true
- });
- } else {
- throw "agreement not accepted"
- }
- }
- else
- throw "wrong user"
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement