Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and add Github Actions #26

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

phillipthelen
Copy link
Member

this is still WIP. As a test I added a GH action to lint the project.

@SabreCat
Copy link
Member

@phillipthelen This looks fantastic! Great job adding all those Actions checks. Might there be a way for us to run this through a staging test? Put it up on a freebie Heroku or Hetzner server and point Staging at it for a little while, see if anything crops up?

@phillipthelen
Copy link
Member Author

I don't have experience setting up our projects on heroku, but it should be possible, yes. Pointing staging to it sounds good.

libs/mobilePayments.js Outdated Show resolved Hide resolved
libs/applePayments.js Outdated Show resolved Hide resolved
let purchaseDataList = iap.getPurchaseData(response);
let subscription = purchaseDataList[0];
const purchaseDataList = iap.getPurchaseData(response);
const subscription = purchaseDataList[0];
if (subscription.expirationDate < jobStartDate) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, the logic is the same but the conditions are inverted, vs Apple... what :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic was also inverted. the if case being cancellation here and another check on iOS. I flipped it here, so that both use the same check/logic for consistency

Copy link
Member

@SabreCat SabreCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a much closer look--probably nitpicky, but while we're in here cleaning house, might be good?

return habitrpgUsers.find(query, {
sort: {_id: 1},
sort: { _id: 1 },
limit: USERS_BATCH,
fields: ['_id', 'apiToken', 'purchased.plan'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same lookup as on Apple, but it doesn't do the blocked user check--

  1. Should it?
  2. Does this suggest we should abstract the find function to a lib?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the block check from Apple. Thinking about it, we don't really want that. If an account is blocked, we'd still want to (properly) cancel their subscription. Otherwise it will get checked over and over.

Moving more code into a lib to avoid code duplication sounds smart. But I would do that in a separate PR.

@@ -13,17 +13,6 @@ var pageLimit = 10;

var SUBSCRIPTION_CANCEL_URL = 'https://habitica.com/amazon/subscribe/cancel';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the BASE_URL from the environment and append the rest of the path?

var gcmLib = require('node-gcm'); // works with FCM notifications too
var AWS = require('aws-sdk');
import nconf from 'nconf';
/*import pushNotify from 'push-notify';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big commented-out file? If we're not handling this here anymore, can we delete it proper-like?

@@ -18,12 +15,12 @@ api.scheduleNextCheckForUser = function scheduleNextCheckForUser (habitrpgUsers,
$set: {
'purchased.plan.lastReminderDate': moment().toDate(),
},
}
},
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to .exec() this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, wait, we're using monk rather than mongoose, is that why?

@@ -84,18 +72,18 @@ api.processUser = function processUser (habitrpgUsers, user, queue, baseUrl, job
'Found user with id', user._id, 'lastReminderDate', user.purchased.plan.lastReminderDate,
'last paymentdate', lastBillingDate.toString(),
'next date', nextBillingDate.toString());
console.log('Plan', plan);*/
console.log('Plan', plan); */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Various commented out console logs--do we need these?

@@ -18,14 +15,14 @@ api.scheduleNextCheckForGroup = function scheduleNextCheckForGroup (habitrpgGrou
$set: {
'purchased.plan.lastReminderDate': moment().toDate(),
},
}
},
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same things in this file as Amazon reminders base--exec? console logs?

server.js Outdated
});
queue.on('failed', (job, error) => {
console.log(error);
/* const args = Array.prototype.slice.call(arguments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More commented out code? I understand on the recap emails, it's a good reminder that such a thing exists and could be enabled again, but what about this?

workers/email.js Outdated
import fs from 'fs';
import nconf from 'nconf';
import mandrill from 'mandrill-api';
import _ from 'lodash';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we only use find and findIndex here, can we import those individually?

const emailsLib = require('../libs/email');
const USERS_BATCH = 10;
import moment from 'moment';
import lodash from 'lodash';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random, template, and assign--
if nothing else, we should probably be consistent about importing it as _ vs lodash!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants