addressing #85
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user