Merge branch 'develop' into party-chat-translations

# Conflicts:
#	test/api/unit/models/group.test.js
This commit is contained in:
Mateus Etto
2018-06-20 20:24:38 +09:00
799 changed files with 42207 additions and 31980 deletions

View File

@@ -327,7 +327,13 @@ api.loginSocial = {
} else { // Create new user
user = {
auth: {
[network]: profile,
[network]: {
id: profile.id,
emails: profile.emails,
},
},
profile: {
name: profile.displayName || profile.name || profile.username,
},
preferences: {
language: req.language,

View File

@@ -312,7 +312,7 @@ api.leaveChallenge = {
if (!challenge.isMember(user)) throw new NotAuthorized(res.t('challengeMemberNotFound'));
// Unlink challenge's tasks from user's tasks and save the challenge
await Promise.all([challenge.unlinkTasks(user, keep), challenge.save()]);
await challenge.unlinkTasks(user, keep);
res.analytics.track('challenge leave', {
uuid: user._id,

View File

@@ -196,6 +196,7 @@ api.createGroupPlan = {
// @TODO: Change message
if (group.privacy !== 'private') throw new NotAuthorized(res.t('partyMustbePrivate'));
group.memberCount = await User.count({ $or: [{ 'party._id': group._id }, { guilds: group._id }] }).exec();
group.leader = user._id;
user.guilds.push(group._id);

View File

@@ -55,7 +55,7 @@ api.getMember = {
// manually call toJSON with minimize: true so empty paths aren't returned
let memberToJSON = member.toJSON({minimize: true});
member.addComputedStatsToJSONObj(memberToJSON.stats);
User.addComputedStatsToJSONObj(memberToJSON.stats, member);
res.respond(200, memberToJSON);
},
@@ -282,16 +282,12 @@ function _getMembersForItem (type) {
.sort({_id: 1})
.limit(limit)
.select(fields)
.lean()
.exec();
// manually call toJSON with minimize: true so empty paths aren't returned
let membersToJSON = members.map(member => {
let memberToJSON = member.toJSON({minimize: true});
if (addComputedStats) member.addComputedStatsToJSONObj(memberToJSON.stats);
return memberToJSON;
});
res.respond(200, membersToJSON);
members.forEach(member => User.transformJSONUser(member, addComputedStats));
res.respond(200, members);
};
}

View File

@@ -3,7 +3,7 @@ import { authWithHeaders } from '../../middlewares/auth';
let api = {};
// @TODO export this const, cannot export it from here because only routes are exported from controllers
const LAST_ANNOUNCEMENT_TITLE = 'FAIRY HATCHING POTIONS RETURN!';
const LAST_ANNOUNCEMENT_TITLE = 'SUMMER SPLASH BEGINS: SUMMER CLASS OUTFITS, SEASONAL SHOP, AND NPC DECORATIONS!';
const worldDmg = { // @TODO
bailey: false,
};
@@ -32,12 +32,33 @@ api.getNews = {
<h1 class="align-self-center">${res.t('newStuff')}</h1>
</div>
</div>
<h2>5/15/2018 - ${LAST_ANNOUNCEMENT_TITLE}</h2>
<h2>6/19/2018 - ${LAST_ANNOUNCEMENT_TITLE}</h2>
<hr/>
<p>They're back! Between now and May 31, you can buy Fairy Hatching Potions from <a href='/shops/market' target='_blank'>the Market</a> and use them to hatch any standard pet egg. (Magic Hatching Potions do not work on Quest Pet eggs.) Fairy Potion Pets aren't picky, so they'll happily eat any kind of food that you feed them!</p>
<p>After they're gone, it will be at least a year before the Fairy Hatching Potions are available again, so be sure to get them now!</p>
<div class="small mb-3">by Edge, Willow the Witty, and SabreCat</div>
<div class="promo_fairy_potions center-block"></div>
<p>To escape the summer heat in Habit City, everyone's moved down to the undersea city of Dilatory. The Summer Splash event has begun!</p>
<div class="media align-items-center">
<div class="media-body">
<h3>Summer Class Outfits</h3>
<p>From now until July 31st, limited edition outfits are available in the Rewards column. Depending on your class, you can be a Lionfish Mage, Fisher-Rogue, Betta Fish Warrior, or Merfolk Monarch Healer! You'd better get productive to earn enough gold before they disappear. Good luck!</p>
<div class="small mb-3">by Vampitch, Vikte, TheDudeAbides, Lalaitha, and Beffymaroo</div>
<div class="media align-items-center">
<div class="promo_seasonal_shop_summer mr-3"></div>
<div class="media-body">
<h3>Seasonal Shop is Open!</h3>
<p>The <a href='/shops/seasonal' target='_blank'>Seasonal Shop</a> has opened! The Seasonal Sorceress is stocking the seasonal edition versions of previous summer outfits, now available for Gems instead of Gold. Plus, there will be more fun things in the shop as the event progresses. The Seasonal Shop will only be open until July 31st, so don't wait!</p>
<div class="small mb-3">by SabreCat, Lemoness, AnnDeLune, Vampitch, nonight, tricksy.fox, Giu09, JaizakAripaik, Teto Forever, and Kai</div>
</div>
</div>
<div class="media align-items-center">
<div class="media-body">
<h3>NPC Costumes and Shop Decorations</h3>
<p>Looks like the NPCs are really getting in to the cheery summer mood around the site. Who wouldn't? After all, there's plenty more celebration to come...</p>
<div class="small mb-3">by Lemoness and Beffymaroo</div>
</div>
<div class="npc_matt ml-3 mb-3"></div>
</div>
</div>
<div class="promo_summer_splash_2018 ml-3"></div>
</div>
</div>
`,
});

View File

@@ -81,7 +81,7 @@ api.inviteToQuest = {
'party._id': group._id,
_id: {$ne: user._id},
})
.select('auth.facebook auth.local preferences.emailNotifications profile.name pushDevices')
.select('auth.facebook auth.google auth.local preferences.emailNotifications profile.name pushDevices')
.exec();
group.markModified('quest');

View File

@@ -8,6 +8,9 @@ import {
basicFields as basicGroupFields,
model as Group,
} from '../../models/group';
import {
model as User,
} from '../../models/user';
import * as Tasks from '../../models/task';
import _ from 'lodash';
import * as passwordUtils from '../../libs/password';
@@ -90,7 +93,7 @@ api.getUser = {
let {daysMissed} = user.daysUserHasMissed(new Date(), req);
userToJSON.needsCron = false;
if (daysMissed > 0) userToJSON.needsCron = true;
user.addComputedStatsToJSONObj(userToJSON.stats);
User.addComputedStatsToJSONObj(userToJSON.stats, userToJSON);
}
return res.respond(200, userToJSON);
@@ -830,7 +833,9 @@ api.buyMysterySet = {
*
* @apiErrorExample {json} Quest chosen does not exist
* {"success":false,"error":"NotFound","message":"Quest \"dilatoryDistress99\" not found."}
* @apiErrorExample {json} NotAuthorized Not enough gold
* @apiErrorExample {json} You must first complete this quest's prerequisites
* {"success":false,"error":"NotAuthorized","message":"You must first complete dilatoryDistress2."}
* @apiErrorExample {json} NotAuthorized Not enough gold
* {"success":false,"error":"NotAuthorized","message":"Not Enough Gold"}
*
*/
@@ -912,7 +917,7 @@ api.buySpecialSpell = {
* }
*
* @apiError {NotAuthorized} messageAlreadyPet Already have the specific pet combination
* @apiError {NotFound} messageMissingEggPotion One or both of the ingrediants are missing.
* @apiError {NotFound} messageMissingEggPotion One or both of the ingredients are missing.
* @apiError {NotFound} messageInvalidEggPotionCombo Cannot use that combination of egg and potion.
*
* @apiErrorExample {json} Already have that pet.
@@ -1902,7 +1907,7 @@ api.movePinnedItem = {
let currentPinnedItemPath = user.pinnedItemsOrder[currentIndex];
if (currentIndex === -1) {
throw new BadRequest(res.t('wrongItemPath', req.language));
throw new BadRequest(res.t('wrongItemPath', {path}, req.language));
}
// Remove the one we will move