mirror of
https://github.com/HabitRPG/habitica.git
synced 2026-04-07 20:52:37 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be7b3076eb | ||
|
|
2b4ffdf27f | ||
|
|
e0dc608fd8 | ||
|
|
294cc63fef | ||
|
|
9a879d566e | ||
|
|
1655e2e03a | ||
|
|
0d444a9d6a | ||
|
|
f4d9c6271b | ||
|
|
0e458683fd | ||
|
|
695a5cc24d | ||
|
|
dcced2debb |
Submodule habitica-images updated: 847f56dd8f...4f18c662a7
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "habitica",
|
||||
"version": "4.234.2",
|
||||
"version": "4.236.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "habitica",
|
||||
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
|
||||
"version": "4.234.2",
|
||||
"version": "4.236.2",
|
||||
"main": "./website/server/index.js",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.18.5",
|
||||
|
||||
@@ -625,6 +625,11 @@
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_bioluminescent_waves {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_bioluminescent_waves.png');
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_birch_forest {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_birch_forest.png');
|
||||
width: 141px;
|
||||
@@ -1884,11 +1889,21 @@
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_underwater_cave {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_underwater_cave.png');
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_underwater_ruins {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_underwater_ruins.png');
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_underwater_statues {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_underwater_statues.png');
|
||||
width: 141px;
|
||||
height: 147px;
|
||||
}
|
||||
.background_underwater_vents {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/background_underwater_vents.png');
|
||||
width: 141px;
|
||||
@@ -2151,6 +2166,11 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_bioluminescent_waves {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_bioluminescent_waves.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_birch_forest {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_birch_forest.png');
|
||||
width: 68px;
|
||||
@@ -3420,11 +3440,21 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_underwater_cave {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_underwater_cave.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_underwater_ruins {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_underwater_ruins.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_underwater_statues {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_underwater_statues.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.icon_background_underwater_vents {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/icon_background_underwater_vents.png');
|
||||
width: 68px;
|
||||
@@ -18145,6 +18175,11 @@
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
}
|
||||
.broad_armor_armoire_fancyPirateSuit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/broad_armor_armoire_fancyPirateSuit.png');
|
||||
width: 114px;
|
||||
height: 90px;
|
||||
}
|
||||
.broad_armor_armoire_farrierOutfit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/broad_armor_armoire_farrierOutfit.png');
|
||||
width: 90px;
|
||||
@@ -18590,6 +18625,11 @@
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
}
|
||||
.head_armoire_fancyPirateHat {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_armoire_fancyPirateHat.png');
|
||||
width: 114px;
|
||||
height: 90px;
|
||||
}
|
||||
.head_armoire_fiddlersCap {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_armoire_fiddlersCap.png');
|
||||
width: 114px;
|
||||
@@ -19175,6 +19215,11 @@
|
||||
width: 114px;
|
||||
height: 87px;
|
||||
}
|
||||
.shield_armoire_treasureMap {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shield_armoire_treasureMap.png');
|
||||
width: 114px;
|
||||
height: 90px;
|
||||
}
|
||||
.shield_armoire_trustyUmbrella {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shield_armoire_trustyUmbrella.png');
|
||||
width: 114px;
|
||||
@@ -19325,6 +19370,11 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_armor_armoire_fancyPirateSuit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_armor_armoire_fancyPirateSuit.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_armor_armoire_farrierOutfit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_armor_armoire_farrierOutfit.png');
|
||||
width: 68px;
|
||||
@@ -19785,6 +19835,11 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_head_armoire_fancyPirateHat {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_armoire_fancyPirateHat.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_head_armoire_fiddlersCap {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_armoire_fiddlersCap.png');
|
||||
width: 68px;
|
||||
@@ -20370,6 +20425,11 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_shield_armoire_treasureMap {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_shield_armoire_treasureMap.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_shield_armoire_trustyUmbrella {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_shield_armoire_trustyUmbrella.png');
|
||||
width: 68px;
|
||||
@@ -20960,6 +21020,11 @@
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
}
|
||||
.slim_armor_armoire_fancyPirateSuit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/slim_armor_armoire_fancyPirateSuit.png');
|
||||
width: 114px;
|
||||
height: 90px;
|
||||
}
|
||||
.slim_armor_armoire_farrierOutfit {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/slim_armor_armoire_farrierOutfit.png');
|
||||
width: 90px;
|
||||
@@ -26830,6 +26895,36 @@
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.broad_armor_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/broad_armor_mystery_202207.png');
|
||||
width: 117px;
|
||||
height: 120px;
|
||||
}
|
||||
.head_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/head_mystery_202207.png');
|
||||
width: 117px;
|
||||
height: 120px;
|
||||
}
|
||||
.shop_armor_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_armor_mystery_202207.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_head_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_head_mystery_202207.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.shop_set_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/shop_set_mystery_202207.png');
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
}
|
||||
.slim_armor_mystery_202207 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/slim_armor_mystery_202207.png');
|
||||
width: 117px;
|
||||
height: 120px;
|
||||
}
|
||||
.broad_armor_mystery_301404 {
|
||||
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/broad_armor_mystery_301404.png');
|
||||
width: 90px;
|
||||
|
||||
@@ -795,6 +795,14 @@
|
||||
"backgroundSailboatAtSunsetText": "Sailboat At Sunset",
|
||||
"backgroundSailboatAtSunsetNotes": "Enjoy the beauty of a sailboat at sunset.",
|
||||
|
||||
"backgrounds072022": "SET 98: Released July 2022",
|
||||
"backgroundBioluminescentWavesText": "Bioluminescent Waves",
|
||||
"backgroundBioluminescentWavesNotes": "Admire the glow of Bioluminescent Waves.",
|
||||
"backgroundUnderwaterCaveText": "Underwater Cave",
|
||||
"backgroundUnderwaterCaveNotes": "Explore an Underwater Cave.",
|
||||
"backgroundUnderwaterStatuesText": "Underwater Statue Garden",
|
||||
"backgroundUnderwaterStatuesNotes": "Try not to blink in an Underwater Statue Garden.",
|
||||
|
||||
"timeTravelBackgrounds": "Steampunk Backgrounds",
|
||||
"backgroundAirshipText": "Airship",
|
||||
"backgroundAirshipNotes": "Become a sky sailor on board your very own Airship.",
|
||||
|
||||
@@ -1185,6 +1185,8 @@
|
||||
"armorMystery202112Notes": "Glide through icy seas and never get cold with this glimmering tail. Confers no benefit. December 2021 Subscriber Item.",
|
||||
"armorMystery202204Text": "Virtual Adventurer Capsule",
|
||||
"armorMystery202204Notes": "Looks like doing your tasks now requires pushing these mysterious buttons! What could they do? Confers no benefit. April 2022 Subscriber Item.",
|
||||
"armorMystery202207Text": "Jammin' Jelly Armor",
|
||||
"armorMystery202207Notes": "This armor will have you looking glamorous and gelatinous. Confers no benefit. July 2022 Subscriber Item.",
|
||||
"armorMystery301404Text": "Steampunk Suit",
|
||||
"armorMystery301404Notes": "Dapper and dashing, wot! Confers no benefit. February 3015 Subscriber Item.",
|
||||
"armorMystery301703Text": "Steampunk Peacock Gown",
|
||||
@@ -1360,6 +1362,8 @@
|
||||
"armorArmoireGardenersOverallsNotes": "Don’t be afraid to work down in the dirt when you’re wearing these durable overalls. Increases Constitution by <%= con %>. Enchanted Armoire: Gardener Set (Item 1 of 4).",
|
||||
"armorArmoireStrawRaincoatText": "Straw Raincoat",
|
||||
"armorArmoireStrawRaincoatNotes": "This woven straw cape will keep you dry and your armor from rusting while on your quest. Just don’t venture too near a candle! Increases Constitution by <%= con %>. Enchanted Armoire: Straw Raincoat Set (Item 1 of 2).",
|
||||
"armorArmoireFancyPirateSuitText": "Fancy Pirate Jacket",
|
||||
"armorArmoireFancyPirateSuitNotes": "Wear this fine jacket well as you organize your ship’s library or talk it through as a crew. Increases Constitution and Intelligence by <%= attrs %> each. Enchanted Armoire: Fancy Pirate Set (Item 1 of 3).",
|
||||
|
||||
"headgear": "helm",
|
||||
"headgearCapitalized": "Headgear",
|
||||
@@ -1918,6 +1922,8 @@
|
||||
"headMystery202202Notes": "You gotta have blue hair! Confers no benefit. February 2022 Subscriber Item.",
|
||||
"headMystery202206Text": "Sea Sprite Circlet",
|
||||
"headMystery202206Notes": "The blue pearl in this circlet grants you waterbending powers. Use them wisely! Confers no benefit. June 2022 Subscriber Item.",
|
||||
"headMystery202207Text": "Jammin' Jelly Helm",
|
||||
"headMystery202207Notes": "Need a hand with your tasks? Will several dozen bioluminescent tentacles do? Confers no benefit. July 2022 Subscriber Item.",
|
||||
"headMystery301404Text": "Fancy Top Hat",
|
||||
"headMystery301404Notes": "A fancy top hat for the finest of gentlefolk! January 3015 Subscriber Item. Confers no benefit.",
|
||||
"headMystery301405Text": "Basic Top Hat",
|
||||
@@ -2091,6 +2097,8 @@
|
||||
"headArmoireGardenersSunHatNotes": "The bright light of the day star won’t shine in your eyes when you wear this wide-brimmed hat. Increases Perception by <%= per %>. Enchanted Armoire: Gardener Set (Item 2 of 4).",
|
||||
"headArmoireStrawRainHatText": "Straw Rain Hat",
|
||||
"headArmoireStrawRainHatNotes": "You’ll be able to spot every obstacle in your path when you wear this water-resistant, conical hat. Increases Perception by <%= per %>. Enchanted Armoire: Straw Raincoat Set (Item 2 of 2).",
|
||||
"headArmoireFancyPirateHatText": "Fancy Pirate Hat",
|
||||
"headArmoireFancyPirateHatNotes": "Be protected from the sun and any seagulls flying overhead as you drink tea on the deck of your ship. Increases Perception by <%= per %>. Enchanted Armoire: Fancy Pirate Set (Item 2 of 3).",
|
||||
|
||||
"offhand": "off-hand item",
|
||||
"offHandCapitalized": "Off-Hand Item",
|
||||
@@ -2477,6 +2485,8 @@
|
||||
"shieldArmoireSpanishGuitarNotes": "Tink! Tink! Thrummm! Gather your party for a concert or celebration by playing this guitar. Increases Perception by <%= per %> and Intelligence by <%= int %>. Enchanted Armoire: Musical Instrument Set 1 (Item 2 of 3)",
|
||||
"shieldArmoireSnareDrumText": "Snare Drum",
|
||||
"shieldArmoireSnareDrumNotes": "Rat-a-tat-tat! Gather your party for a parade or march into battle by playing this drum. Increases Constitution by <%= con %> and Intelligence by <%= int %>. Enchanted Armoire: Musical Instrument Set 1 (Item 3 of 3)",
|
||||
"shieldArmoireTreasureMapText": "Treasure Map",
|
||||
"shieldArmoireTreasureMapNotes": "X marks the spot! You never know what you’ll find when you follow this handy map to fabled treasures: gold, jewels, relics, or perhaps a petrified orange? Increases Strength and Intelligence by <%= attrs %> each. Enchanted Armoire: Fancy Pirate Set (Item 3 of 3).",
|
||||
|
||||
"back": "Back Accessory",
|
||||
"backBase0Text": "No Back Accessory",
|
||||
|
||||
@@ -203,11 +203,13 @@
|
||||
"transaction_gift_send": "Gifted to",
|
||||
"transaction_gift_receive": "Received from",
|
||||
"transaction_create_challenge": "Created challenge",
|
||||
"transaction_create_bank_challenge": "Created bank challenge",
|
||||
"transaction_create_guild": "Created guild",
|
||||
"transaction_change_class": "Changed class",
|
||||
"transaction_rebirth": "Used Orb of Rebirth",
|
||||
"transaction_release_pets": "Released pets",
|
||||
"transaction_release_mounts": "Released mounts",
|
||||
"transaction_reroll": "Used Fortify Potion",
|
||||
"transaction_subscription_perks": "From subscription perk"
|
||||
"transaction_subscription_perks": "From subscription perk",
|
||||
"transaction_admin_update_balance": "Admin given"
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@
|
||||
"mysterySet202204": "Virtual Adventurer Set",
|
||||
"mysterySet202205": "Dusk-Winged Dragon Set",
|
||||
"mysterySet202206": "Sea Sprite Set",
|
||||
"mysterySet202207": "Jammin' Jelly Set",
|
||||
"mysterySet301404": "Steampunk Standard Set",
|
||||
"mysterySet301405": "Steampunk Accessories Set",
|
||||
"mysterySet301703": "Peacock Steampunk Set",
|
||||
|
||||
@@ -505,6 +505,11 @@ const backgrounds = {
|
||||
mountain_waterfall: { },
|
||||
sailboat_at_sunset: { },
|
||||
},
|
||||
backgrounds072022: {
|
||||
bioluminescent_waves: { },
|
||||
underwater_cave: { },
|
||||
underwater_statues: { },
|
||||
},
|
||||
timeTravelBackgrounds: {
|
||||
airship: {
|
||||
price: 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import t from '../translation';
|
||||
import prefill from './prefill';
|
||||
import { EVENTS } from '../constants';
|
||||
|
||||
export default prefill({
|
||||
baseHair1: { setPrice: 5, text: t('hairSet1') },
|
||||
@@ -29,7 +30,7 @@ export default prefill({
|
||||
setPrice: 5, availableFrom: '2021-09-28T08:00-04:00', availableUntil: '2021-10-31T20:00-04:00', text: t('supernaturalSkins'),
|
||||
},
|
||||
splashySkins: {
|
||||
setPrice: 5, availableFrom: '2021-07-13T08:00-04:00', availableUntil: '2021-07-31T20:00-04:00', text: t('splashySkins'),
|
||||
setPrice: 5, availableFrom: '2022-07-05T08:00-05:00', availableUntil: EVENTS.summer2022.end, text: t('splashySkins'),
|
||||
},
|
||||
winterySkins: {
|
||||
setPrice: 5, availableFrom: '2021-12-23T08:00-05:00', availableUntil: '2022-01-31T20:00-05:00', text: t('winterySkins'),
|
||||
|
||||
@@ -396,6 +396,11 @@ const armor = {
|
||||
con: 9,
|
||||
set: 'strawRaincoat',
|
||||
},
|
||||
fancyPirateSuit: {
|
||||
con: 4,
|
||||
int: 4,
|
||||
set: 'fancyPirate',
|
||||
},
|
||||
};
|
||||
|
||||
const body = {
|
||||
@@ -803,6 +808,10 @@ const head = {
|
||||
per: 9,
|
||||
set: 'strawRaincoat',
|
||||
},
|
||||
fancyPirateHat: {
|
||||
per: 8,
|
||||
set: 'fancyPirate',
|
||||
},
|
||||
};
|
||||
|
||||
const shield = {
|
||||
@@ -1086,6 +1095,11 @@ const shield = {
|
||||
int: 6,
|
||||
set: 'musicalInstrumentOne',
|
||||
},
|
||||
treasureMap: {
|
||||
int: 4,
|
||||
str: 4,
|
||||
set: 'fancyPirate',
|
||||
},
|
||||
};
|
||||
|
||||
const headAccessory = {
|
||||
|
||||
@@ -57,6 +57,7 @@ const armor = {
|
||||
202110: { },
|
||||
202112: { },
|
||||
202204: { },
|
||||
202207: { },
|
||||
301404: { },
|
||||
301703: { },
|
||||
301704: { },
|
||||
@@ -190,6 +191,7 @@ const head = {
|
||||
202112: { },
|
||||
202202: { },
|
||||
202206: { },
|
||||
202207: { },
|
||||
301404: { },
|
||||
301405: { },
|
||||
301703: { },
|
||||
|
||||
@@ -398,7 +398,7 @@ spells.special = {
|
||||
target: 'user',
|
||||
notes: t('spellSpecialSeafoamNotes'),
|
||||
canOwn () {
|
||||
return moment().isBetween('2021-07-06T08:00-04:00', EVENTS.summer2021.end);
|
||||
return moment().isBetween('2022-07-12T08:00-04:00', EVENTS.summer2022.end);
|
||||
},
|
||||
cast (user, target, req) {
|
||||
if (!user.items.special.seafoam) throw new NotAuthorized(t('spellNotOwned')(req.language));
|
||||
|
||||
@@ -267,7 +267,11 @@ api.updateHero = {
|
||||
const hero = await User.findById(heroId).exec();
|
||||
if (!hero) throw new NotFound(res.t('userWithIDNotFound', { userId: heroId }));
|
||||
|
||||
if (updateData.balance) hero.balance = updateData.balance;
|
||||
if (updateData.balance) {
|
||||
await hero.updateBalance(updateData.balance - hero.balance, 'admin_update_balance', '', 'Given by Habitica staff');
|
||||
|
||||
hero.balance = updateData.balance;
|
||||
}
|
||||
|
||||
// give them gems if they got an higher level
|
||||
// tier = level in this context
|
||||
@@ -323,7 +327,9 @@ api.updateHero = {
|
||||
}
|
||||
}
|
||||
|
||||
if (updateData.changeApiToken) hero.apiToken = common.uuid();
|
||||
if (updateData.changeApiToken) {
|
||||
hero.apiToken = common.uuid();
|
||||
}
|
||||
|
||||
const savedHero = await hero.save();
|
||||
const heroJSON = savedHero.toJSON();
|
||||
|
||||
@@ -714,8 +714,8 @@ api.transferGems = {
|
||||
throw new NotAuthorized(res.t('badAmountOfGemsToSend'));
|
||||
}
|
||||
|
||||
await receiver.updateBalance(amount, 'gift_receive', sender._id, sender.profile.name);
|
||||
await sender.updateBalance(-amount, 'gift_send', sender._id, receiver.profile.name);
|
||||
await receiver.updateBalance(amount, 'gift_receive', sender._id, sender.auth.local.username);
|
||||
await sender.updateBalance(-amount, 'gift_send', sender._id, receiver.auth.local.username);
|
||||
// @TODO necessary? Also saved when sending the inbox message
|
||||
const promises = [receiver.save(), sender.save()];
|
||||
await Promise.all(promises);
|
||||
|
||||
@@ -64,9 +64,15 @@ api.purchaseHistory = {
|
||||
req.checkParams('memberId', res.t('memberIdRequired')).notEmpty().isUUID();
|
||||
const validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
const transactions = await Transaction
|
||||
let transactions = await Transaction
|
||||
.find({ userId: req.params.memberId })
|
||||
.sort({ createdAt: -1 });
|
||||
.sort({ createdAt: -1 })
|
||||
.exec();
|
||||
|
||||
if (!res.locals.user.hasPermission('userSupport')) {
|
||||
transactions = transactions.filter(t => t.transactionType !== 'create_bank_challenge');
|
||||
}
|
||||
|
||||
res.respond(200, transactions);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -74,14 +74,16 @@ export async function createChallenge (user, req, res) {
|
||||
if (groupBalance >= prizeCost) {
|
||||
// Group pays for all of prize
|
||||
group.balance -= prizeCost;
|
||||
|
||||
await user.updateBalance(0, 'create_bank_challenge', challenge._id, challenge.name);
|
||||
} else if (groupBalance > 0) {
|
||||
// User pays remainder of prize cost after group
|
||||
const remainder = prizeCost - group.balance;
|
||||
group.balance = 0;
|
||||
await user.updateBalance(-remainder, 'create_challenge', challenge._id, challenge.text);
|
||||
await user.updateBalance(-remainder, 'create_challenge', challenge._id, challenge.name);
|
||||
} else {
|
||||
// User pays for all of prize
|
||||
await user.updateBalance(-prizeCost, 'create_challenge', challenge._id, challenge.text);
|
||||
await user.updateBalance(-prizeCost, 'create_challenge', challenge._id, challenge.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ schema.methods.updateHourglasses = async function updateHourglasses (userId,
|
||||
amount,
|
||||
reference,
|
||||
referenceText,
|
||||
|
||||
currentAmount: this.consecutive.trinkets,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import baseModel from '../libs/baseModel';
|
||||
const { Schema } = mongoose;
|
||||
|
||||
export const currencies = ['gems', 'hourglasses'];
|
||||
export const transactionTypes = ['buy_money', 'buy_gold', 'contribution', 'spend', 'gift_send', 'gift_receive', 'debug', 'create_challenge', 'create_guild', 'change_class', 'rebirth', 'release_pets', 'release_mounts', 'reroll', 'contribution', 'subscription_perks'];
|
||||
export const transactionTypes = ['buy_money', 'buy_gold', 'spend', 'gift_send', 'gift_receive', 'debug', 'create_challenge', 'create_bank_challenge', 'create_guild', 'change_class', 'rebirth', 'release_pets', 'release_mounts', 'reroll', 'contribution', 'subscription_perks', 'admin_update_balance'];
|
||||
|
||||
export const schema = new Schema({
|
||||
currency: { $type: String, enum: currencies, required: true },
|
||||
@@ -13,6 +13,7 @@ export const schema = new Schema({
|
||||
reference: { $type: String },
|
||||
referenceText: { $type: String },
|
||||
amount: { $type: Number, required: true },
|
||||
currentAmount: { $type: Number },
|
||||
userId: {
|
||||
$type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid for Transaction.'],
|
||||
},
|
||||
@@ -23,7 +24,17 @@ export const schema = new Schema({
|
||||
});
|
||||
|
||||
schema.plugin(baseModel, {
|
||||
noSet: ['id', '_id', 'userId', 'currency', 'transactionType', 'reference', 'referenceText', 'amount'], // Nothing can be set from the client
|
||||
noSet: [
|
||||
'id',
|
||||
'_id',
|
||||
'userId',
|
||||
'currency',
|
||||
'transactionType',
|
||||
'reference',
|
||||
'referenceText',
|
||||
'amount',
|
||||
'currentAmount',
|
||||
], // Nothing can be set from the client
|
||||
timestamps: true,
|
||||
_id: false, // using custom _id
|
||||
});
|
||||
|
||||
@@ -559,5 +559,6 @@ schema.methods.updateBalance = async function updateBalance (amount,
|
||||
amount,
|
||||
reference,
|
||||
referenceText,
|
||||
currentAmount: this.balance,
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user