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
2018-04-01 02:59:54 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'APRIL FOOL\'S 2018: TINY PETS AND MOUNTS!' ;
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" >
< div class = "media" >
2018-02-07 02:03:30 +00:00
< div class = "align-self-center mr-3 ${baileyClass}" > < / d i v >
2018-02-02 00:31:38 +00:00
< div class = "media-body" >
2018-02-07 02:03:30 +00:00
< h1 class = "align-self-center" > $ { res . t ( 'newStuff' ) } < / h 1 >
2018-02-02 00:31:38 +00:00
< / d i v >
2018-01-31 10:55:39 +00:00
< / d i v >
2018-04-01 02:59:54 +00:00
< h2 > 4 / 1 / 2018 - $ { LAST _ANNOUNCEMENT _TITLE } < / h 2 >
2018-02-07 02:03:30 +00:00
< hr / >
2018-03-15 19:04:00 +00:00
< div class = "media align-items-center" >
< div class = "media-body" >
2018-04-01 02:59:54 +00:00
< h3 > Tiny Pets and Mounts < / h 3 >
< p > Oh no ! That dastardly April Fool seems to have pulled off his "small" prank : all our pets and mounts have shrunk ! < / p >
< p > "Haha!" the April Fool laughs as he bursts in the the Tavern , "Enjoy your new and more efficiently-sized friends! Now your pets and mounts are so much easier to keep track of, right? This should certainly increase your productivity!" < / p >
2018-03-22 19:50:47 +00:00
< / d i v >
2018-04-01 02:59:54 +00:00
< div class = "npc_aprilFool" > < / d i v >
2018-03-22 19:50:47 +00:00
< / d i v >
2018-04-01 02:59:54 +00:00
< p > Lady Glaciate grumbles from her corner table and looks at her mammoth , which is happily cavorting in her teacup . "Well, since I don't have a ride back home to the Stoikalm Steppes at the moment, I disagree." < / p >
< p > As Sir Stomp sprays tea triumphantly from his trunk , a small smile tugs at the corner of her mouth . ".…I suppose one could argue it's quite cute, though," she grudgingly adds . < / p >
< p > It looks like all our pets and mounts are extra small for the time being . Enjoy the fun by checking out everyone ' s profiles today ! Your pets and mounts will return to normal on April 3. < / p >
< h3 > Special April Fool ' s Social Media Challenge ! < / h 3 >
< p > For even more fun , check out the < a href = '/challenges/a7cacfb6-3135-4d17-9a51-46dfcfe1e712' target = '_blank' > 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 t i n y p e t s 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 ! < / p >
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' ,
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 => {
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 ;