mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 10:11:25 +08:00
18 lines
685 B
JavaScript
18 lines
685 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);
|
|
PubsubConnector.notifyAccountChange(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}) => {
|
|
// })
|
|
}
|