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-06-19 00:20:14 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'SUMMER SPLASH BEGINS! CLASS OUTFITS, SEASONAL SHOP, ORCAS, AND NPC DECORATIONS' ;
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-06-19 00:20:14 +00:00
< h2 > 6 / 18 / 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-06-19 00:20:14 +00:00
< p > To escape the summer heat in Habit City , everyone ' s moved down to the undersea city of Dilatory . The Summer Splash event has begun ! < / p >
< div class = "promo_summer_splash_2019 center-block" > < / d i v >
< h3 > Summer Class Outfits < / h 3 >
< p > From now until July 31 st , limited edition outfits are available in the Rewards column . Depending on your class , you can be a Sea Turtle Warrior , Hammerhead Rogue , Conch Healer , or Water Lily Mage ! You ' d better get productive to earn enough gold before they disappear . Good luck ! < / p >
< div class = "small mb-3" > by AnnDeLune , gawrone , Vikte , and SabreCat < / d i v >
< div class = "promo_seasonal_shop center-block" > < / d i v >
< h3 > Seasonal Shop is Open ! < / h 3 >
< p > The < a href = '/shops/seasonal' > Seasonal Shop < / a > h a s o p e n e d ! T h e S e a s o n a l S o r c e r e s s i s s t o c k i n g t h e s e a s o n a l e d i t i o n v e r s i o n s o f p r e v i o u s s u m m e r o u t f i t s , n o w a v a i l a b l e f o r G e m s i n s t e a d o f G o l d . P l u s , t h e r e w i l l b e m o r e f u n t h i n g s i n t h e s h o p a s t h e e v e n t p r o g r e s s e s . T h e S e a s o n a l S h o p w i l l o n l y b e o p e n u n t i l J u l y 3 1 s t , s o d o n ' t w a i t ! < / p >
< div class = "small mb-3" > by SabreCat , Lemoness , Giu09 , JaizakAripaik , Teto Forever , Kai , AnnDeLune , Vampitch , TheDudeAbides , Lalaitha , nonight , tricksy . fox , and Beffymaroo < / d i v >
< div class = "promo_orcas center-block" > < / d i v >
< h3 > Orcas for Everyone ! < / h 3 >
< p > Dolphins aren 't the only animals riding the waves around the city of Dilatory: it looks like some friendly Orcas are swimming into Habiticans' stables ! In honor of the Summer Splash event , everyone who didn ' t already have an Orca gets either the mount or the pet . Enjoy ! < / p >
< div class = "small mb-3" > by Beffymaroo and UncommonCriminal < / d i v >
< div class = "npc_matt center-block" > < / d i v >
< h3 > NPC Costumes < / h 3 >
< p > Looks like the NPCs are really getting in to the cheery summer mood around the site . Who wouldn 't? After all, there' s plenty more celebration to come ... < / p >
< div class = "small mb-3" > by 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 ;