addressing #85

This commit is contained in:
les 2020-08-27 22:12:36 +02:00
parent fde382f9e8
commit f9dd4e05f7

View file

@ -35,8 +35,10 @@ module.exports = {
}
// sync db
const db = require('./api/models')
const users = await db.user.findAll()
const db = require('./api/models/index')
const User = require('./api/models/user')
const Notification = require('./api/models/notification')
const users = await User.findAll()
if (users.length) {
consola.warn(' ⚠ Non empty db! Please move your current db elsewhere than retry.')
return false
@ -44,7 +46,7 @@ module.exports = {
// create admin user
consola.info(`Create admin with email: ${admin.email}`)
await db.user.create({
await User.create({
email: admin.email,
password: admin.password,
is_admin: true,
@ -61,18 +63,18 @@ module.exports = {
// })
// send confirmed events to mastodon
await db.notification.create({ action: 'Create', type: 'ap', filters: { is_visible: true } })
await db.notification.create({ action: 'Update', type: 'ap', filters: { is_visible: true } })
await db.notification.create({ action: 'Delete', type: 'ap', filters: { is_visible: true } })
await Notification.create({ action: 'Create', type: 'ap', filters: { is_visible: true } })
await Notification.create({ action: 'Update', type: 'ap', filters: { is_visible: true } })
await Notification.create({ action: 'Delete', type: 'ap', filters: { is_visible: true } })
// send anon events to admin
await db.notification.create({ action: 'Create', type: 'admin_email', filters: { is_visible: false } })
await Notification.create({ action: 'Create', type: 'admin_email', filters: { is_visible: false } })
// TODO email's notifications
// await db.notification.create({ action: 'Create', type: 'email', filters: { is_visible: true } })
// close db connection
await db.sequelize.close()
await db.close()
return true
}