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-04-01 15:17:05 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'THE APRIL FOOL STRIKES AGAIN!' ;
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-04-01 15:17:05 +00:00
< h2 > 4 / 1 / 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-04-01 15:17:05 +00:00
< div class = "promo_april_fools_2019 center-block" > < / d i v >
< h3 > Fruit and Veggie Pets and NPCs < / h 3 >
< p > The April Fool has appeared , and he 's got a farmer' s market ' s worth of produce in tow . < / p >
< p > "HAHA!" he cries , as a dragonfruit bounces along beside him . "I've always thought good humor should be healthful and nourishing, so I've gone back to my roots, if you will, to bring some plant-powered goodness into Habitica once again!" < / p >
< p > "He's replaced all our equipped pets with fruits and vegetables!" says QuartzFox , gently patting a contented - looking tomato . "Although to be fair, they are very cute fruits and vegetables!" < / p >
< p > Equipping different pets will show different fruits and veggies . Have fun discovering them all ! < / p >
2019-04-02 12:53:37 +00:00
< p > The NPCs have also been turned into their fruit and vegetable forms as a tribute to Habitica 's <a href="https://habitica.fandom.com/wiki/April_Fools' _Day _2014 " target = '_blank' > very first April Fool ' s prank back in 2014 < / a > ! G o c h e c k t h e m o u t . < / p >
2019-04-01 15:17:05 +00:00
< h3 > Special April Fool ' s Social Media Challenge ! < / h 3 >
< p > For even more fun , check out the < a href = '/challenges/b0337534-ec69-4269-8cc6-f74c91881451' > official Challenge < / a > p o s t e d e s p e c i a l l y f o r t o d a y ! S h a r e y o u r a v a t a r f e a t u r i n g y o u r n e w f r u i t a n d v e g g i e p e t o n s o c i a l m e d i a b e t w e e n n o w a n d A p r i l 3 , a n d y o u ' l l h a v e a c h a n c e t o w i n g e m s a n d h a v e y o u r a v a t a r f e a t u r e d o n t h e H a b i t i c a B l o g ! < / p >
< div class = "small mb-3" > by Beffymaroo , SabreCat , Piyo , Viirus , and Lemoness < / d i v >
2019-04-01 15:24:55 +00:00
< div class = "npc_aprilFool center-block" > < / 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 ;