Commit 37895087 authored by les's avatar les
Browse files

start a new fediverse experience

parent f1d54c77
......@@ -8,7 +8,7 @@ const settingsController = require('./settings')
const get = require('lodash/get')
const botController = {
bot: null,
bots: null,
async initialize() {
const access_token = get(settingsController.secretSettings, 'mastodon_auth.access_token')
const instance = get(settingsController.settings, 'mastodon_instance')
......
......@@ -79,38 +79,38 @@ const settingsController = {
res.json(settings)
},
async getAuthURL(req, res) {
const instance = req.body.instance
const callback = `${config.baseurl}/api/settings/oauth`
const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
'gancio', 'read write', callback)
const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
`https://${instance}`, 'read write', callback)
// async getAuthURL(req, res) {
// const instance = req.body.instance
// const callback = `${config.baseurl}/api/settings/oauth`
// const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
// 'gancio', 'read write', callback)
// const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
// `https://${instance}`, 'read write', callback)
await settingsController.set('mastodon_instance', instance )
await settingsController.set('mastodon_auth', { client_id, client_secret }, true)
res.json(url)
},
// await settingsController.set('mastodon_instance', instance )
// await settingsController.set('mastodon_auth', { client_id, client_secret }, true)
// res.json(url)
// },
async code(req, res) {
const code = req.query.code
const callback = `${config.baseurl}/api/settings/oauth`
const client_id = settingsController.secretSettings.mastodon_auth.client_id
const client_secret = settingsController.secretSettings.mastodon_auth.client_secret
const instance = settingsController.settings.mastodon_instance
// async code(req, res) {
// const code = req.query.code
// const callback = `${config.baseurl}/api/settings/oauth`
// const client_id = settingsController.secretSettings.mastodon_auth.client_id
// const client_secret = settingsController.secretSettings.mastodon_auth.client_secret
// const instance = settingsController.settings.mastodon_instance
try {
const access_token = await Mastodon.getAccessToken(client_id, client_secret, code,
`https://${instance}`, callback)
const mastodon_auth = { client_id, client_secret, access_token }
await settingsController.set('mastodon_auth', mastodon_auth, true)
const botController = require('./bot')
botController.initialize()
res.redirect('/admin')
} catch (e) {
res.json(e)
}
},
// try {
// const access_token = await Mastodon.getAccessToken(client_id, client_secret, code,
// `https://${instance}`, callback)
// const mastodon_auth = { client_id, client_secret, access_token }
// await settingsController.set('mastodon_auth', mastodon_auth, true)
// const botController = require('./fediverse')
// botController.initialize()
// res.redirect('/admin')
// } catch (e) {
// res.json(e)
// }
// },
}
setTimeout(settingsController.initialize, 200)
......
......@@ -3,6 +3,13 @@ const bcrypt = require('bcryptjs')
module.exports = (sequelize, DataTypes) => {
const user = sequelize.define('user', {
username: {
type: DataTypes.STRING,
unique: true,
index: true,
allowNull: false
},
display_name: DataTypes.STRING,
email: {
type: DataTypes.STRING,
unique: true,
......
const mail = require('./api/mail')
const bot = require('./api/controller/bot')
const bot = require('./api/controller/fediverse')
const settingsController = require('./api/controller/settings')
const config = require('config')
const eventController = require('./api/controller/event')
......@@ -10,6 +10,7 @@ const { event: Event, notification: Notification, event_notification: EventNoti
const notifier = {
async sendNotification(notification, event) {
return
const promises = []
switch (notification.type) {
case 'mail':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment