mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
start a new fediverse experience
This commit is contained in:
parent
f1d54c776f
commit
37895087c0
4 changed files with 39 additions and 31 deletions
|
@ -8,7 +8,7 @@ const settingsController = require('./settings')
|
||||||
const get = require('lodash/get')
|
const get = require('lodash/get')
|
||||||
|
|
||||||
const botController = {
|
const botController = {
|
||||||
bot: null,
|
bots: null,
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const access_token = get(settingsController.secretSettings, 'mastodon_auth.access_token')
|
const access_token = get(settingsController.secretSettings, 'mastodon_auth.access_token')
|
||||||
const instance = get(settingsController.settings, 'mastodon_instance')
|
const instance = get(settingsController.settings, 'mastodon_instance')
|
|
@ -79,38 +79,38 @@ const settingsController = {
|
||||||
res.json(settings)
|
res.json(settings)
|
||||||
},
|
},
|
||||||
|
|
||||||
async getAuthURL(req, res) {
|
// async getAuthURL(req, res) {
|
||||||
const instance = req.body.instance
|
// const instance = req.body.instance
|
||||||
const callback = `${config.baseurl}/api/settings/oauth`
|
// const callback = `${config.baseurl}/api/settings/oauth`
|
||||||
const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
|
// const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
|
||||||
'gancio', 'read write', callback)
|
// 'gancio', 'read write', callback)
|
||||||
const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
|
// const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
|
||||||
`https://${instance}`, 'read write', callback)
|
// `https://${instance}`, 'read write', callback)
|
||||||
|
|
||||||
await settingsController.set('mastodon_instance', instance )
|
// await settingsController.set('mastodon_instance', instance )
|
||||||
await settingsController.set('mastodon_auth', { client_id, client_secret }, true)
|
// await settingsController.set('mastodon_auth', { client_id, client_secret }, true)
|
||||||
res.json(url)
|
// res.json(url)
|
||||||
},
|
// },
|
||||||
|
|
||||||
async code(req, res) {
|
// async code(req, res) {
|
||||||
const code = req.query.code
|
// const code = req.query.code
|
||||||
const callback = `${config.baseurl}/api/settings/oauth`
|
// const callback = `${config.baseurl}/api/settings/oauth`
|
||||||
const client_id = settingsController.secretSettings.mastodon_auth.client_id
|
// const client_id = settingsController.secretSettings.mastodon_auth.client_id
|
||||||
const client_secret = settingsController.secretSettings.mastodon_auth.client_secret
|
// const client_secret = settingsController.secretSettings.mastodon_auth.client_secret
|
||||||
const instance = settingsController.settings.mastodon_instance
|
// const instance = settingsController.settings.mastodon_instance
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
const access_token = await Mastodon.getAccessToken(client_id, client_secret, code,
|
// const access_token = await Mastodon.getAccessToken(client_id, client_secret, code,
|
||||||
`https://${instance}`, callback)
|
// `https://${instance}`, callback)
|
||||||
const mastodon_auth = { client_id, client_secret, access_token }
|
// const mastodon_auth = { client_id, client_secret, access_token }
|
||||||
await settingsController.set('mastodon_auth', mastodon_auth, true)
|
// await settingsController.set('mastodon_auth', mastodon_auth, true)
|
||||||
const botController = require('./bot')
|
// const botController = require('./fediverse')
|
||||||
botController.initialize()
|
// botController.initialize()
|
||||||
res.redirect('/admin')
|
// res.redirect('/admin')
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
res.json(e)
|
// res.json(e)
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(settingsController.initialize, 200)
|
setTimeout(settingsController.initialize, 200)
|
||||||
|
|
|
@ -3,6 +3,13 @@ const bcrypt = require('bcryptjs')
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const user = sequelize.define('user', {
|
const user = sequelize.define('user', {
|
||||||
|
username: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true,
|
||||||
|
index: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
display_name: DataTypes.STRING,
|
||||||
email: {
|
email: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const mail = require('./api/mail')
|
const mail = require('./api/mail')
|
||||||
const bot = require('./api/controller/bot')
|
const bot = require('./api/controller/fediverse')
|
||||||
const settingsController = require('./api/controller/settings')
|
const settingsController = require('./api/controller/settings')
|
||||||
const config = require('config')
|
const config = require('config')
|
||||||
const eventController = require('./api/controller/event')
|
const eventController = require('./api/controller/event')
|
||||||
|
@ -10,6 +10,7 @@ const { event: Event, notification: Notification, event_notification: EventNoti
|
||||||
|
|
||||||
const notifier = {
|
const notifier = {
|
||||||
async sendNotification(notification, event) {
|
async sendNotification(notification, event) {
|
||||||
|
return
|
||||||
const promises = []
|
const promises = []
|
||||||
switch (notification.type) {
|
switch (notification.type) {
|
||||||
case 'mail':
|
case 'mail':
|
||||||
|
|
Loading…
Reference in a new issue