import Queue from 'bull' ;
export const create = ( name ) => {
// I'm not clear on the semantics of the bull queues.
// Should I make one per process and use it in all functions?
// Or, make one for every place I need it and don't share them?
return new Queue ( name ) ;
}
export const send _registration = ( user ) => {
const mail = create ( "mail/registration" ) ;
mail . add ( { user } ) ;
}
export const send _welcome = ( user ) => {
const mail = create ( "mail/welcome" ) ;
mail . add ( { user } ) ;
}
export const send _receipt = ( user , payment _id , product _id ) => {
const mail = create ( "mail/receipt" ) ;
mail . add ( { user , payment _id , product _id } ) ;
}
export const send _reset = ( user , ip _address , browser ) => {
const mail = create ( "mail/reset" ) ;
mail . add ( { user , ip _address , browser } ) ;
}
export const send _reset _finished = ( user , ip _address , browser ) => {
const mail = create ( "mail/reset_finished" ) ;
mail . add ( { user , ip _address , browser } ) ;
}
export const send _update _viewers = ( api _key ) => {
const live = create ( "live/update_viewers" ) ;
live . add ( { api _key } ) ;
}
export const add _view _count = ( livestream _id ) => {
const live = create ( "live/add_view_count" ) ;
live . add ( { livestream _id } ) ;
}
export default {
create , send _welcome , send _reset , send _reset _finished , send _update _viewers
}