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-02-12 19:48:13 +00:00
const LAST _ANNOUNCEMENT _TITLE = 'VALENTINE’ S DAY CELEBRATION! INCLUDING CUPID AND ROSE QUARTZ HATCHING POTIONS' ;
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-02-12 13:19:58 +00:00
< h2 > 2 / 12 / 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-02-12 13:19:58 +00:00
< div class = "promo_valentines center-block" > < / d i v >
< h3 > Habitica Celebrates Valentine ' s Day ! < / h 3 >
< p > In honor of Habitica 's holiday celebrating all forms of love, whether it' s friendship , familial , or romantic , some of the shopkeepers are dressed up ! Take a look around to enjoy their new festive decorations . < / p >
< div class = "small mb-3" > by Beffymaroo and Lemoness < / d i v >
< h3 > Send a Valentine < / h 3 >
< p > Help motivate all of the lovely people in your life by sending them a caring Valentine . For the next week only , Valentines can be purchased for 10 Gold from the < a href = '/shops/market' > Market < / a > . F o r s p r e a d i n g l o v e a n d j o y t h r o u g h o u t t h e c o m m u n i t y , b o t h t h e g i v e r A N D t h e r e c e i v e r g e t a c o v e t e d " A d o r i n g F r i e n d s " b a d g e . H o o r a y ! < / p >
< p > While you ' re there , why not check out the other cards that are available to send to your party ? Each one gives a special achievement of its own ... < / p >
< div class = "small mb-3" > By Lemoness and SabreCat < / d i v >
< div class = "promo_valentines_potions center-block" > < / d i v >
< h3 > Cupid and Rose Quartz Hatching Potions < / h 3 >
< p > There 's a new pet breed in town! We' re excited to introduce the new Rose Quartz Magic Hatching Potions , and to announce the return of Cupid Potions ! Between now and February 28 , you can buy these potions from < a href = '/shops/market' > the Market < / a > a n d u s e t h e m t o h a t c h a n y s t a n d a r d p e t e g g . ( M a g i c H a t c h i n g P o t i o n s d o n o t w o r k o n Q u e s t P e t e g g s . ) M a g i c P o t i o n P e t s a r e n ' t p i c k y , s o t h e y ' l l h a p p i l y e a t a n y k i n d o f f o o d t h a t y o u f e e d t h e m ! < / p >
< p > After they ' re gone , it will be at least a year before the Cupid or Rose Quartz Hatching Potions are available again , so be sure to get them now ! < / p >
< div class = "small mb-3" > by Vampitch , Willow the Witty , and SabreCat < / 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 ;