Skip to content

Commit

Permalink
Merge 1d50a44 into 039439d
Browse files Browse the repository at this point in the history
  • Loading branch information
paglias committed Jun 17, 2018
2 parents 039439d + 1d50a44 commit a867473
Show file tree
Hide file tree
Showing 42 changed files with 163 additions and 159 deletions.
6 changes: 5 additions & 1 deletion webpack/config/index.js
Expand Up @@ -41,11 +41,15 @@ module.exports = {
assetsPublicPath: '/',
staticAssetsDirectory,
proxyTable: {
// proxy all requests starting with /api/v3 to IP:PORT as specified in the top-level config
// proxy all requests to the server at IP:PORT as specified in the top-level config
'/api/v3': {
target: DEV_BASE_URL,
changeOrigin: true,
},
'/api/v4': {
target: DEV_BASE_URL,
changeOrigin: true,
},
'/stripe': {
target: DEV_BASE_URL,
changeOrigin: true,
Expand Down
12 changes: 6 additions & 6 deletions website/client/app.vue
Expand Up @@ -306,7 +306,7 @@ export default {
// Don't show errors from getting user details. These users have delete their account,
// but their chat message still exists.
let configExists = Boolean(error.response) && Boolean(error.response.config);
if (configExists && error.response.config.method === 'get' && error.response.config.url.indexOf('/api/v3/members/') !== -1) {
if (configExists && error.response.config.method === 'get' && error.response.config.url.indexOf('/api/v4/members/') !== -1) {
// @TODO: We resolve the promise because we need our caching to cache this user as tried
// Chat paging should help this, but maybe we can also find another solution..
return Promise.resolve(error);
Expand Down Expand Up @@ -348,20 +348,20 @@ export default {
const url = response.config.url;
const method = response.config.method;
const isApiCall = url.indexOf('api/v3') !== -1;
const isApiCall = url.indexOf('api/v4') !== -1;
const userV = response.data && response.data.userV;
const isCron = url.indexOf('/api/v3/cron') === 0 && method === 'post';
const isCron = url.indexOf('/api/v4/cron') === 0 && method === 'post';
if (this.isUserLoaded && isApiCall && userV) {
const oldUserV = this.user._v;
this.user._v = userV;
// Do not sync again if already syncing
const isUserSync = url.indexOf('/api/v3/user') === 0 && method === 'get';
const isTasksSync = url.indexOf('/api/v3/tasks/user') === 0 && method === 'get';
const isUserSync = url.indexOf('/api/v4/user') === 0 && method === 'get';
const isTasksSync = url.indexOf('/api/v4/tasks/user') === 0 && method === 'get';
// exclude chat seen requests because with real time chat they would be too many
const isChatSeen = url.indexOf('/chat/seen') !== -1 && method === 'post';
// exclude POST /api/v3/cron because the user is synced automatically after cron runs
// exclude POST /api/v4/cron because the user is synced automatically after cron runs
// Something has changed on the user object that was not tracked here, sync the user
if (userV - oldUserV > 1 && !isCron && !isChatSeen && !isUserSync && !isTasksSync) {
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/achievements/death.vue
Expand Up @@ -66,7 +66,7 @@ export default {
this.$root.$emit('bv::hide::modal', 'death');
},
async revive () {
await axios.post('/api/v3/user/revive');
await axios.post('/api/v4/user/revive');
revive(this.user);
this.close();
},
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/achievements/newStuff.vue
Expand Up @@ -40,7 +40,7 @@
async mounted () {
this.$root.$on('bv::show::modal', async (modalId) => {
if (modalId !== 'new-stuff') return;
let response = await axios.get('/api/v3/news');
let response = await axios.get('/api/v4/news');
this.html = response.data.html;
});
},
Expand Down
10 changes: 5 additions & 5 deletions website/client/components/appFooter.vue
Expand Up @@ -308,20 +308,20 @@ export default {
let date = moment(this.user.lastCron).subtract(numberOfDays, 'days').toDate();
await axios.post('/api/v3/debug/set-cron', {
await axios.post('/api/v4/debug/set-cron', {
lastCron: date,
});
// @TODO: Notification.text('-' + numberOfDays + ' day(s), remember to refresh');
// @TODO: Sync user?
},
async addTenGems () {
await axios.post('/api/v3/debug/add-ten-gems');
await axios.post('/api/v4/debug/add-ten-gems');
// @TODO: Notification.text('+10 Gems!');
this.user.balance += 2.5;
},
async addHourglass () {
await axios.post('/api/v3/debug/add-hourglass');
await axios.post('/api/v4/debug/add-hourglass');
// @TODO: Sync?
},
addGold () {
Expand Down Expand Up @@ -356,13 +356,13 @@ export default {
});
},
async addQuestProgress () {
await axios.post('/api/v3/debug/quest-progress');
await axios.post('/api/v4/debug/quest-progress');
// @TODO: Notification.text('Quest progress increased');
// @TODO: User.sync();
},
async makeAdmin () {
await axios.post('/api/v3/debug/make-admin');
await axios.post('/api/v4/debug/make-admin');
// @TODO: Notification.text('You are now an admin! Go to the Hall of Heroes to change your contributor level.');
// @TODO: sync()
Expand Down
6 changes: 3 additions & 3 deletions website/client/components/auth/registerLoginReset.vue
Expand Up @@ -370,7 +370,7 @@ export default {
}
// @TODO: implement langauge and invite accepting
// var url = ApiUrl.get() + "/api/v3/user/auth/local/register";
// var url = ApiUrl.get() + "/api/v4/user/auth/local/register";
// if (location.search && location.search.indexOf('Invite=') !== -1) { // matches groupInvite and partyInvite
// url += location.search;
// }
Expand Down Expand Up @@ -481,7 +481,7 @@ export default {
return;
}
await axios.post('/api/v3/user/reset-password', {
await axios.post('/api/v4/user/reset-password', {
email: this.username,
});
Expand All @@ -499,7 +499,7 @@ export default {
return;
}
const res = await axios.post('/api/v3/user/auth/reset-password-set-new-one', {
const res = await axios.post('/api/v4/user/auth/reset-password-set-new-one', {
newPassword: this.password,
confirmPassword: this.passwordConfirm,
code: this.resetPasswordSetNewOneData.code,
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/challenges/challengeDetail.vue
Expand Up @@ -381,7 +381,7 @@ export default {
// let response = await this.$store.dispatch('challenges:exportChallengeCsv', {
// challengeId: this.searchId,
// });
window.location = `/api/v3/challenges/${this.searchId}/export/csv`;
window.location = `/api/v4/challenges/${this.searchId}/export/csv`;
},
cloneChallenge () {
this.$root.$emit('habitica:clone-challenge', {
Expand Down
Expand Up @@ -38,7 +38,7 @@ export default {
reward: [],
};
let response = await axios.get(`/api/v3/challenges/${this.challengeId}/members/${this.memberId}`);
let response = await axios.get(`/api/v4/challenges/${this.challengeId}/members/${this.memberId}`);
let tasks = response.data.data.tasks;
tasks.forEach((task) => {
this.tasksByType[task.type].push(task);
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/chat/chatCard.vue
Expand Up @@ -253,7 +253,7 @@ export default {
this.$emit('message-removed', message);
if (this.inbox) {
axios.delete(`/api/v3/user/messages/${message.id}`);
axios.delete(`/api/v4/user/messages/${message.id}`);
this.$delete(this.user.inbox.messages, message.id);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/chat/chatMessages.vue
Expand Up @@ -164,7 +164,7 @@ export default {
if (Boolean(uuid) && !this.cachedProfileData[uuid] && !aboutToCache[uuid]) {
if (uuid === 'system' || this.currentProfileLoadedCount === this.currentProfileLoadedEnd) return;
aboutToCache[uuid] = {};
promises.push(axios.get(`/api/v3/members/${uuid}`));
promises.push(axios.get(`/api/v4/members/${uuid}`));
this.currentProfileLoadedCount += 1;
}
});
Expand Down
4 changes: 2 additions & 2 deletions website/client/components/creatorIntro.vue
Expand Up @@ -1441,7 +1441,7 @@ export default {
});
// @TODO: Move to the action
let response = await axios.post('/api/v3/tasks/user', tasksToCreate);
let response = await axios.post('/api/v4/tasks/user', tasksToCreate);
let tasks = response.data.data;
tasks.forEach(task => {
this.$store.state.user.data.tasksOrder[`${task.type}s`].unshift(task._id);
Expand Down Expand Up @@ -1512,7 +1512,7 @@ export default {
}
}
await axios.post(`/api/v3/user/unlock?path=${path}`);
await axios.post(`/api/v4/user/unlock?path=${path}`);
try {
unlock(this.user, {
query: {
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/header/userDropdown.vue
Expand Up @@ -98,7 +98,7 @@ export default {
},
showInbox () {
markPMSRead(this.user);
axios.post('/api/v3/user/mark-pms-read');
axios.post('/api/v4/user/mark-pms-read');
this.$root.$emit('bv::show::modal', 'inbox-modal');
},
showProfile (startingPage) {
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/inventory/items/cards-modal.vue
Expand Up @@ -54,7 +54,7 @@ export default {
},
methods: {
async readCard () {
await axios.post(`/api/v3/user/read-card/${this.cardType}`);
await axios.post(`/api/v4/user/read-card/${this.cardType}`);
this.user.items.special[`${this.cardType}Received`].shift();
this.user.flags.cardReceived = false;
this.close();
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/modifyInventory.vue
Expand Up @@ -294,7 +294,7 @@ export default {
}
},
async modifyInventory () {
await axios.post('/api/v3/debug/modify-inventory', {
await axios.post('/api/v4/debug/modify-inventory', {
gear: this.showInv.gear ? this.inv.gear : null,
special: this.showInv.special ? this.inv.special : null,
pets: this.showInv.pets ? this.inv.pets : null,
Expand Down
4 changes: 2 additions & 2 deletions website/client/components/notifications.vue
Expand Up @@ -399,7 +399,7 @@ export default {
},
async runYesterDailiesAction () {
// Run Cron
await axios.post('/api/v3/cron');
await axios.post('/api/v4/cron');
// Notifications
Expand Down Expand Up @@ -532,7 +532,7 @@ export default {
let userReadNotifsPromise = false;
if (notificationsToRead.length > 0) {
await axios.post('/api/v3/notifications/read', {
await axios.post('/api/v4/notifications/read', {
notificationIds: notificationsToRead,
});
}
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/payments/amazonModal.vue
Expand Up @@ -206,7 +206,7 @@ export default {
let url = '/amazon/subscribe';
if (this.amazonPayments.groupToCreate) {
url = '/api/v3/groups/create-plan';
url = '/api/v4/groups/create-plan';
}
try {
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/settings/deleteModal.vue
Expand Up @@ -47,7 +47,7 @@ export default {
this.$root.$emit('bv::hide::modal', 'reset');
},
async deleteAccount () {
await axios.delete('/api/v3/user', {
await axios.delete('/api/v4/user', {
data: {
password: this.password,
feedback: this.feedback,
Expand Down
4 changes: 2 additions & 2 deletions website/client/components/settings/promoCode.vue
Expand Up @@ -40,7 +40,7 @@ export default {
...mapState({user: 'user.data', credentials: 'credentials'}),
getCodesUrl () {
if (!this.user) return '';
return `/api/v3/coupons?_id=${this.user._id}&apiToken=${this.credentials.API_TOKEN}`;
return `/api/v4/coupons?_id=${this.user._id}&apiToken=${this.credentials.API_TOKEN}`;
},
},
methods: {
Expand All @@ -53,7 +53,7 @@ export default {
// })
},
async enterCoupon () {
let code = await axios.post(`/api/v3/coupons/enter/${this.couponCode}`);
let code = await axios.post(`/api/v4/coupons/enter/${this.couponCode}`);
if (!code) return;
this.$store.state.user.data = code.data.data;
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/settings/resetModal.vue
Expand Up @@ -20,7 +20,7 @@ export default {
this.$root.$emit('bv::hide::modal', 'reset');
},
async reset () {
let response = await axios.post('/api/v3/user/reset');
let response = await axios.post('/api/v4/user/reset');
// @TODO: Not sure if this is correct
this.$store.user = response.data.data.user;
this.$router.push('/');
Expand Down
10 changes: 5 additions & 5 deletions website/client/components/settings/site.vue
Expand Up @@ -335,7 +335,7 @@ export default {
},
async saveDayStart () {
this.user.preferences.dayStart = this.newDayStart;
await axios.post('/api/v3/user/custom-day-start', {
await axios.post('/api/v4/user/custom-day-start', {
dayStart: this.newDayStart,
});
// @TODO
Expand All @@ -348,7 +348,7 @@ export default {
setTimeout(() => window.location.reload(true));
},
async changeUser (attribute, updates) {
await axios.put(`/api/v3/user/auth/update-${attribute}`, updates);
await axios.put(`/api/v4/user/auth/update-${attribute}`, updates);
alert(this.$t(`${attribute}Success`));
this.user[attribute] = updates[attribute];
},
Expand All @@ -362,7 +362,7 @@ export default {
this.$root.$emit('bv::show::modal', 'delete');
},
async deleteSocialAuth (network) {
await axios.delete(`/api/v3/user/auth/social/${network.key}`);
await axios.delete(`/api/v4/user/auth/social/${network.key}`);
this.text(this.$t('detachedSocial', {network: network.name}));
},
async socialAuth (network) {
Expand All @@ -378,13 +378,13 @@ export default {
if (confirmationNeeded && !confirm(this.$t('changeClassConfirmCost'))) return;
try {
changeClass(this.user);
await axios.post('/api/v3/user/change-class');
await axios.post('/api/v4/user/change-class');
} catch (e) {
alert(e.message);
}
},
addLocalAuth () {
axios.post('/api/v3/user/auth/local/register', this.localAuth, 'addedLocalAuth');
axios.post('/api/v4/user/auth/local/register', this.localAuth, 'addedLocalAuth');
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/settings/subscription.vue
Expand Up @@ -248,7 +248,7 @@ export default {
});
},
async applyCoupon (coupon) {
const response = await axios.post(`/api/v3/coupons/validate/${coupon}`);
const response = await axios.post(`/api/v4/coupons/validate/${coupon}`);
if (!response.data.data.valid) return;
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/static/newStuff.vue
Expand Up @@ -16,7 +16,7 @@ export default {
};
},
async mounted () {
let response = await axios.get('/api/v3/news');
let response = await axios.get('/api/v4/news');
this.html = response.data.html;
},
};
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/tasks/task.vue
Expand Up @@ -718,7 +718,7 @@ export default {
if (task.group.approval.required) task.group.approval.requested = true;
Analytics.updateUser();
const response = await axios.post(`/api/v3/tasks/${task._id}/score/${direction}`);
const response = await axios.post(`/api/v4/tasks/${task._id}/score/${direction}`);
const tmp = response.data.data._tmp || {}; // used to notify drops, critical hits and other bonuses
const crit = tmp.crit;
const drop = tmp.drop;
Expand Down
4 changes: 2 additions & 2 deletions website/client/components/userMenu/profile.vue
Expand Up @@ -507,12 +507,12 @@ export default {
},
blockUser () {
this.userLoggedIn.inbox.blocks.push(this.user._id);
axios.post(`/api/v3/user/block/${this.user._id}`);
axios.post(`/api/v4/user/block/${this.user._id}`);
},
unblockUser () {
let index = this.userLoggedIn.inbox.blocks.indexOf(this.user._id);
this.userLoggedIn.inbox.blocks.splice(index, 1);
axios.post(`/api/v3/user/block/${this.user._id}`);
axios.post(`/api/v4/user/block/${this.user._id}`);
},
openSendGemsModal () {
this.userReceivingGems = this.user;
Expand Down
2 changes: 1 addition & 1 deletion website/client/components/userMenu/profileStats.vue
Expand Up @@ -305,7 +305,7 @@
if (this.statUpdates[stat] > 0) statUpdates[stat] = this.statUpdates[stat];
});
await axios.post('/api/v3/user/allocate-bulk', {
await axios.post('/api/v4/user/allocate-bulk', {
stats: statUpdates,
});
Expand Down
2 changes: 1 addition & 1 deletion website/client/index.html
Expand Up @@ -24,6 +24,6 @@

<script type="text/javascript" src="//cloudfront.loggly.com/js/loggly.tracker-latest.min.js" async></script>
<!-- Translations -->
<script type='text/javascript' src='/api/v3/i18n/browser-script'></script>
<script type='text/javascript' src='/api/v4/i18n/browser-script'></script>
</body>
</html>
2 changes: 1 addition & 1 deletion website/client/mixins/payments.js
Expand Up @@ -73,7 +73,7 @@ export default {
let url = '/stripe/checkout?a=a'; // just so I can concat &x=x below

if (data.groupToCreate) {
url = '/api/v3/groups/create-plan?a=a';
url = '/api/v4/groups/create-plan?a=a';
res.groupToCreate = data.groupToCreate;
res.paymentType = 'Stripe';
}
Expand Down

0 comments on commit a867473

Please sign in to comment.