mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Login Incentives (#8230)
* feat(incentives): login bennies WIP * feat(content): incentive prize content WIP * fix(content): placeholders pass tests * WIP(content): Bard instrument placeholder * feat(content): Incentives build * chore(sprites): compile and fix some strings * WIP(incentives): quests and backgrounds * fix(quests): correct buy/launch handling * [WIP] Incentives rewarding (#8226) * Added login incentive rewards * Updated incentive rewards * Added incentive modal and updated notification structure * Added analytics to sleeping * Added login incentives to user analytics * Fixed unit tests and ensured that prizes are incremented and not replaced * Updated style of daily login incentive modal * Added rewards modal * Added translations * Added loigin incentive ui elements to profile * Updated login incentives structure and abstracted to common.content * Added dynamic display for login incentives on profile * Added purple potion image * Updated daily login modal * Fixed progress calculation * Added bard gear * Updated login incentive rewards * Fixed styles and text * Added multiple read for notifications * Fixed lint issues * Fixed styles and added 50 limit * Updated quest keys * Added login incentives reward page * Fixed tests * Fixed linting and tests * Read named notifications route. Add image for backgrounds * Fixed style issues and added tranlsations to login incentive notification * Hided abiltiy to purchase incentive backgrounds and added message to detail how to unlock * Updated awarded message * Fixed text and updated progress counter to display better * Fixed purple potion reward text * Fixed check in backgrouns reward text * fix(quest): pass tests * Added display of multiple rewards * Updated modal styles * Fixed neagtive 50 issue * Remvoed total count from daily login incentives modal * Fixed magic paw display * fix(awards): give bunnies again * WIP(incentives): more progress on BG shop * fix(incentives): actually award backgrounds * fix(incentives): more BG fixy * fix(backgrounds): don't gem-buy checkin bgs * Added dust bunny notification * fix(incentives): don't redisplay bunny award * chore(news): Bailey and different promo sprite
This commit is contained in:
@@ -43,4 +43,44 @@ api.readNotification = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @apiIgnore Not yet part of the public API
|
||||
* @api {post} /api/v3/notifications Mark notifications as read
|
||||
* @apiName ReadNotifications
|
||||
* @apiGroup Notification
|
||||
*
|
||||
*
|
||||
* @apiSuccess {Object} data user.notifications
|
||||
*/
|
||||
api.readNotifications = {
|
||||
method: 'POST',
|
||||
url: '/notifications/read',
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
req.checkBody('notificationIds', res.t('notificationsRequired')).notEmpty();
|
||||
|
||||
let validationErrors = req.validationErrors();
|
||||
if (validationErrors) throw validationErrors;
|
||||
|
||||
let notifications = req.body.notificationIds;
|
||||
for (let notification of notifications) {
|
||||
let index = _.findIndex(user.notifications, {
|
||||
id: notification,
|
||||
});
|
||||
|
||||
if (index === -1) {
|
||||
throw new NotFound(res.t('messageNotificationNotFound'));
|
||||
}
|
||||
|
||||
user.notifications.splice(index, 1);
|
||||
}
|
||||
|
||||
await user.save();
|
||||
|
||||
res.respond(200, user.notifications);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
|
||||
@@ -9,7 +9,7 @@ let api = {};
|
||||
* @apiName GetMarketItems
|
||||
* @apiGroup Shops
|
||||
*
|
||||
* @apiSuccess {Object} data List of push devices
|
||||
* @apiSuccess {Object} data List of available items
|
||||
* @apiSuccess {string} message Success message
|
||||
*/
|
||||
api.getMarketItems = {
|
||||
@@ -37,7 +37,7 @@ api.getMarketItems = {
|
||||
* @apiName GetQuestShopItems
|
||||
* @apiGroup Shops
|
||||
*
|
||||
* @apiSuccess {Object} data List of push devices
|
||||
* @apiSuccess {Object} data List of available quests
|
||||
* @apiSuccess {string} message Success message
|
||||
*/
|
||||
api.getQuestShopItems = {
|
||||
@@ -65,7 +65,7 @@ api.getQuestShopItems = {
|
||||
* @apiName GetTimeTravelersShopItems
|
||||
* @apiGroup Shops
|
||||
*
|
||||
* @apiSuccess {Object} data List of push devices
|
||||
* @apiSuccess {Object} data List of available items
|
||||
* @apiSuccess {string} message Success message
|
||||
*/
|
||||
api.getTimeTravelerShopItems = {
|
||||
@@ -94,7 +94,7 @@ api.getTimeTravelerShopItems = {
|
||||
* @apiName GetSeasonalShopItems
|
||||
* @apiGroup Shops
|
||||
*
|
||||
* @apiSuccess {Object} data List of push devices
|
||||
* @apiSuccess {Object} data List of available items
|
||||
* @apiSuccess {string} message Success message
|
||||
*/
|
||||
api.getSeasonalShopItems = {
|
||||
@@ -116,4 +116,32 @@ api.getSeasonalShopItems = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @apiIgnore
|
||||
* @api {get} /api/v3/shops/backgrounds get the available items for the backgrounds shop
|
||||
* @apiName GetBackgroundsShopItems
|
||||
* @apiGroup Shops
|
||||
*
|
||||
* @apiSuccess {Object} data List of available backgrounds
|
||||
* @apiSuccess {string} message Success message
|
||||
*/
|
||||
api.getBackgroundShopItems = {
|
||||
method: 'GET',
|
||||
url: '/shops/backgrounds',
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
|
||||
let resObject = {
|
||||
identifier: 'backgroundShop',
|
||||
text: res.t('backgroundShop'),
|
||||
notes: res.t('backgroundShopText'),
|
||||
imageName: 'background_shop',
|
||||
sets: shops.getBackgroundShopSets(user, req.language),
|
||||
};
|
||||
|
||||
res.respond(200, resObject);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user