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-09 19:59:30 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'APRIL FOOLS CHALLENGE WINNERS, GARDEN HATCHING POTIONS, AND SPRING AVATAR CUSTOMIZATIONS' ;
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-09 19:59:30 +00:00
< h2 > 4 / 9 / 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-09 19:59:30 +00:00
< h3 > April Fool ' s Challenge Winners and Blog Post ! < / h 3 >
< p > The winners of the April Fool ' s Social Media Challenge have been selected ! Congratulations to : isaaleonardo , Bee _ , kitt - haven , alittleofeverything , and Zelah _Meyer ! < / p >
< p > Thank you to everyone who shared their awesome pics with their fruit and veggie pets ! You can see a fun < a href = 'https://habitica.wordpress.com/2019/04/09/guac-this-way-fruit-and-veggie-pet-pics-from-habiticas-april-fools-celebration/' target = '_blank' > recap of the shenanigans on our blog < / a > . S t a y t u n e d t o s e e w h a t w a c k y a n t i c s t h e F o o l g e t s u p t o n e x t y e a r ! < / p >
< div class = "promo_april_fools_2019 center-block" > < / d i v >
< h3 > Garden Magic Hatching Potions < / h 3 >
< p > The April Fool returns to the Tavern , wearing his trademarked mischievious grin and pulling a wagon whose contents are covered with a colorful cloth . < / p >
< p > "I'm so glad everyone enjoyed my <strong>wholesome</strong> joke!" he declares , tossing confetti in the air as he often does . "Since you all had so much fun, I've brought you another surprise!" < / p >
< p > He dramatically pulls away the cloth to reveal that the wagon is filled with potion bottles ! Each bottle seems to contain a shape - shifting vegetable . < / p >
< p > "Now you can keep your fruit and veggie pets all year round!" he says . "Take good care of them, and I'll see you all again soon. I guess I've really outdone myself so I have some serious planning to do before next year..." With that , the Fool takes his leave , disappearing in a puff of lettuce leaves and leaving the cart full of potions . < / p >
< p > Thanks to the April Fool , you can purchase Garden Magic Hatching Potions in the Market between now and April 30 ! Garden pets do not have mount forms ( yet ! ) so keep that in mind when you 're purchasing. After they' re gone , it will be at least a year before Garden Magic Potions are available again , so be sure to get them now ! < / p >
< div class = "small mb-3" > by Beffymaroo , Piyo , and SabreCat < / d i v >
< div class = "promo_spring_avatar_customizations center-block" > < / d i v >
< h3 > Shimmer Hair Colors and Pastel Skin Set < / h 3 >
< p > The Seasonal Edition Shimmer Hair Colors and Pastel Skin Set are now available for purchase in the User > Edit Avatar ! These skin sets will only be available to purchase until April 30 th , and then they will disappear from the shop until next Spring Fling . If you buy them , though , you will have access to them year - round ! < / p >
< div class = "small mb-3" > by Lemoness and McCoyly < / 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 ;