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 = 'WINTER WONDERLAND BEGINS! AND DECEMBER MYSTERY ITEMS REVEALED'; const worldDmg = { // @TODO bailey: false, }; /** * @api {get} /api/v3/news Get latest Bailey announcement * @apiName GetNews * @apiGroup News * * * @apiSuccess {Object} html Latest Bailey html * */ api.getNews = { method: 'GET', url: '/news', async handler (req, res) { const baileyClass = worldDmg.bailey ? 'npc_bailey_broken' : 'npc_bailey'; res.status(200).send({ html: `

${res.t('newStuff')}

12/20/2018 - ${LAST_ANNOUNCEMENT_TITLE}


Winter Wonderland Begins!

A wintery breeze is blowing in from the Stoïkalm Steppes, and the snow is gently drifting down over Habit City. The Winter Wonderland event has begun!

Winter Class Outfits

From now until January 31st, limited edition outfits are available in the Rewards column. Depending on your class, you can be a Blizzard Warrior, a Poinsettia Rogue, a Pyrotechnic Mage, or a Winter Star Healer! You'd better get productive to earn enough gold before they disappear. Good luck!

by Lt Cabel, Vikte, AnnDeLune, Persephone, SabreCat, shanaqui, and Beffymaroo

Seasonal Shop is Open!

The Seasonal Shop has opened! The Seasonal Sorceress is stocking the seasonal edition versions of previous winter outfits, now available for gems instead of gold, and the two winter quests, Trapper Santa and Find the Cub. Plus, there will be more fun things in the shop as the event progresses.The Seasonal Shop will only be open until January 31st, so don't wait!

by SabreCat and Lemoness

NPC Costumes

Looks like the NPCs are really getting in to the cheery winter mood around the site. Who wouldn't? After all, there's plenty more celebration to come...

by Lemoness

December Subscriber Items Revealed!

The December Subscriber Set has been revealed: the Arctic Fox Item Set! You only have until December 31 to receive the item set when you subscribe. If you're already an active subscriber, reload the site and then head to Inventory > Items to claim your gear!

Subscribers also receive the ability to buy Gems with Gold -- the longer you subscribe, the more Gems you can buy per month! There are other perks as well, such as longer access to uncompressed data and a cute Jackalope pet. Best of all, subscriptions let us keep Habitica running. Thank you very much for your support -- it means a lot to us.

by Beffymaroo
`, }); }, }; /** * @api {post} /api/v3/news/tell-me-later Get latest Bailey announcement in a second moment * @apiName TellMeLaterNews * @apiGroup News * * * @apiSuccess {Object} data An empty Object * */ api.tellMeLaterNews = { method: 'POST', middlewares: [authWithHeaders()], url: '/news/tell-me-later', async handler (req, res) { const user = res.locals.user; user.flags.newStuff = false; const existingNotificationIndex = user.notifications.findIndex(n => { return n && n.type === 'NEW_STUFF'; }); if (existingNotificationIndex !== -1) user.notifications.splice(existingNotificationIndex, 1); user.addNotification('NEW_STUFF', { title: LAST_ANNOUNCEMENT_TITLE }, true); // seen by default await user.save(); res.respond(200, {}); }, }; module.exports = api;