2018-01-31 10:55:39 +00:00
import { authWithHeaders } from '../../middlewares/auth' ;
let api = { } ;
// @TODO export this const, cannot export it from here because only routes are exported from controllers
2019-07-31 18:13:27 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'HABITICA NAMING DAY! AND LAST CHANCE FOR SUMMER LIMITED ITEMS' ;
2018-01-31 10:55:39 +00:00
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 : `
< div class = "bailey" >
2018-08-30 18:56:36 +00:00
< div class = "media align-items-center" >
2018-09-11 20:38:12 +00:00
< div class = "mr-3 ${baileyClass}" > < / d i v >
2018-06-19 23:24:40 +00:00
< div class = "media-body" >
2018-09-11 20:38:12 +00:00
< h1 class = "align-self-center" > $ { res . t ( 'newStuff' ) } < / h 1 >
2019-07-31 18:13:27 +00:00
< h2 > 7 / 31 / 2019 - $ { LAST _ANNOUNCEMENT _TITLE } < / h 2 >
2018-08-30 18:56:36 +00:00
< / d i v >
< / d i v >
2018-09-11 20:38:12 +00:00
< hr / >
2019-07-31 18:13:27 +00:00
< div class = "promo_naming_day_2018 center-block" > < / d i v >
< h3 > Habitica Naming Day ! < / h 3 >
< p > Happy Habitica Naming Day ! In honor of the day when we changed the name of the app from HabitRPG to Habitica , we 've given everyone an achievement, as well as some delicious cake for your pets and mounts. Everyone has also received Royal Purple Gryphon rewards! Depending on how many Naming Days you' ve celebrated with us , you ' ve received Melior ( a Purple Gryphon mount ) , his little sister Meliora ( a Purple Gryphon pet ) , a Purple Gryphon Helm , or the Purple Gryphon Wing Cloak ! < / p >
< p > Thanks for being a Habitica user -- you all mean so much to us . We hope that you enjoy your presents ! < / p >
< div class = "small mb-3" > by Lemoness , Beffymaroo , and Baconsaur < / d i v >
2019-07-25 19:58:07 +00:00
< div class = "promo_mystery_201907 center-block" > < / d i v >
2019-07-31 18:13:27 +00:00
< h3 > Last Chance for Beach Buddy Set < / h 3 >
< p > Reminder : this is the final day to < a href = '/user/settings/subscription' > subscribe < / a > a n d r e c e i v e t h e t h r e e - p i e c e B e a c h B u d d y S e t ! S u b s c r i b i n g a l s o l e t s y o u b u y G e m s f o r G o l d . T h e l o n g e r y o u r s u b s c r i p t i o n , t h e m o r e G e m s y o u g e t ! < / p >
< p > Thanks so much for your support ! You help keep Habitica running . < / p >
2019-07-25 19:58:07 +00:00
< div class = "small mb-3" > by Beffymaroo < / d i v >
2019-07-31 18:13:27 +00:00
< div class = "promo_summer_splash_2019 center-block" > < / d i v >
< h3 > Last Chance for Summer Splash Items and Hatching Potions < / h 3 >
< p > This is also your last chance to get all Summer Splash goodies before they vanish at the end of July 31 st ! This includes Limited - Edition Outfits , Seasonal Shop purchases , Seasonal Edition Skins , and yes , even Watery and Glass Hatching Potions . Grab them all while you still can ! < / p >
< div class = "promo_splashy_pals_bundle center-block" > < / d i v >
< h3 > Last Chance for Splashy Pals Pet Quest Bundle < / h 3 >
< p > This is also the final day to buy the discounted Splashy Pals Pet Quest Bundle , featuring the Seahorse , Sea Turtle , and Whale quests all for seven gems ! Be sure to catch it in the < a href = '/shops/quests' > Quest Shop < / a > b e f o r e i t s w i m s a w a y ! < / p >
< div class = "small" > by Lemoness and SabreCat < / d i v >
< div class = "small" > Art by McCoyly , krazjega , UncommonCriminal , zoebeagle , Kiwibot , JessicaChase , Scarabsi , and JaizakArpaik < / d i v >
< div class = "small mb-3" > Writing by Calae , Ginger _Hanna , and Lemoness < / d i v >
2018-01-31 10:55:39 +00:00
< / d i v >
` ,
} ) ;
} ,
} ;
/ * *
* @ 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' ,
2018-09-21 13:12:20 +00:00
middlewares : [ authWithHeaders ( ) ] ,
2018-01-31 10:55:39 +00:00
url : '/news/tell-me-later' ,
async handler ( req , res ) {
const user = res . locals . user ;
user . flags . newStuff = false ;
const existingNotificationIndex = user . notifications . findIndex ( n => {
2018-02-04 12:28:05 +00:00
return n && n . type === 'NEW_STUFF' ;
2018-01-31 10:55:39 +00:00
} ) ;
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 , { } ) ;
} ,
} ;
2018-02-02 00:31:38 +00:00
module . exports = api ;