mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 21:24:58 +08:00
18 lines
627 B
JavaScript
18 lines
627 B
JavaScript
|
const PubsubConnector = require('./pubsub-connector')
|
||
|
|
||
|
module.exports = (db, sequelize) => {
|
||
|
sequelize.addHook("afterCreate", ({dataValues, $modelOptions}) => {
|
||
|
if ($modelOptions.name.singular === 'Account') {
|
||
|
PubsubConnector.broadcastClient().lpushAsync('accounts:unclaimed', dataValues.id);
|
||
|
}
|
||
|
})
|
||
|
sequelize.addHook("afterUpdate", ({dataValues, $modelOptions}) => {
|
||
|
if ($modelOptions.name.singular === 'Account') {
|
||
|
PubsubConnector.notifyAccountChange(dataValues.id);
|
||
|
}
|
||
|
})
|
||
|
// TODO delete account from redis
|
||
|
// sequelize.addHook("afterDelete", ({dataValues, $modelOptions}) => {
|
||
|
// })
|
||
|
}
|