Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
0eb41a1e
Commit
0eb41a1e
authored
Aug 25, 2019
by
les
Browse files
cleaning
parent
0de68b50
Changes
13
Hide whitespace changes
Inline
Side-by-side
locales/email/it.json
View file @
0eb41a1e
{
"email.register.subject"
:
"Richiesta registrazione ricevuta"
,
"email.register"
:
"Abbiamo ricevuto la richiesta di registrazione. La confermeremo quanto prima.
\n
Ciao"
,
"email.confirm"
:
"Il tuo account su
gancio
è stato attivato e quindi puoi cominciare a pubblicare eventi"
,
"email.confirm"
:
"Il tuo account su
{{config.title}}
è stato attivato e quindi puoi cominciare a pubblicare eventi"
,
"email.recover.subject"
:
"Recupero password"
,
"email.recover"
:
"Ciao, hai richiesto un recupero della password su
gancio
."
,
"email.recover"
:
"Ciao, hai richiesto un recupero della password su
{{config.title}}
."
,
"email.press_here"
:
"Premi qui"
,
"email.confirm.subject"
:
"Registrazione confermata"
,
"email.user_confirm"
:
"Ciao, il tuo account su <a href='{{config.baseurl}}'>{{config.title}}<a/> è stato creato. <a href='{{config.baseurl}}/user_confirm/{{user.recover_code}}'>Confermalo</a>."
...
...
locales/it.js
View file @
0eb41a1e
...
...
@@ -50,7 +50,7 @@ export default {
me
:
'
Sei te
'
,
password_updated
:
'
Password modificata!
'
,
username
:
'
Nickname
'
,
comments
:
'
C
ommenti
'
comments
:
'
|un commento|{n} c
ommenti
'
},
login
:
{
...
...
server/api/controller/event.js
View file @
0eb41a1e
...
...
@@ -5,6 +5,7 @@ const lodash = require('lodash')
const
{
event
:
Event
,
comment
:
Comment
,
tag
:
Tag
,
place
:
Place
,
user
:
User
,
notification
:
Notification
}
=
require
(
'
../models
'
)
const
Sequelize
=
require
(
'
sequelize
'
)
const
notifier
=
require
(
'
../../notifier
'
)
const
federation
=
require
(
'
../../federation/helpers
'
)
const
eventController
=
{
...
...
@@ -120,7 +121,8 @@ const eventController = {
res
.
sendStatus
(
200
)
// send notification
notifier
.
notifyEvent
(
event
.
id
)
//notifier.notifyEvent(event.id)
//federation.sendEvent(event, req.user)
}
catch
(
e
)
{
res
.
sendStatus
(
404
)
}
...
...
server/api/controller/fediverse.js
deleted
100644 → 0
View file @
0de68b50
// const fs = require('fs')
// const path = require('path')
// const moment = require('moment')
// const { event: Event, comment: Comment } = require('../models')
// const config = require('config')
// const settingsController = require('./settings')
// const get = require('lodash/get')
// const botController = {
// bots: null,
// async initialize() {
// const access_token = get(settingsController.secretSettings, 'mastodon_auth.access_token')
// const instance = get(settingsController.settings, 'mastodon_instance')
// if (!access_token || !instance) return
// botController.bot = new Mastodon({
// access_token,
// api_url: `https://${instance}/api/v1`
// })
// const listener = botController.bot.stream('/streaming/user')
// listener.on('message', botController.message)
// listener.on('error', botController.error)
// },
// async post(event) {
// const status = `${event.title} @${event.place.name} ${moment(event.start_datetime).format('ddd, D MMMM HH:mm')} -
// ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : event.description} - ${event.tags.map(t => '#' + t.tag).join(' ')} ${config.baseurl}/event/${event.id}`
// let media
// if (event.image_path) {
// const file = path.resolve(config.upload_path, event.image_path)
// if (fs.statSync(file)) {
// media = await botController.bot.post('/media', { file: fs.createReadStream(file) })
// }
// }
// return botController.bot.post('/statuses', { status, media_ids: media ? [media.data.id] : [] })
// },
// async message(msg) {
// const type = msg.event
// if (type === 'delete') {
// const activitypub_id = String(msg.data)
// const event = await Comment.findOne({ where: { activitypub_id } })
// if (event) await event.destroy()
// return
// }
// const activitypub_id = String(msg.data.status.in_reply_to_id)
// if (!activitypub_id) return
// let event = await Event.findOne({ where: { activitypub_id } })
// if (!event) {
// // check for comment..
// const comment = await Comment.findOne( { include: [Event], where: { activitypub_id }})
// if (!comment) return
// event = comment.event
// }
// await Comment.create({
// activitypub_id: String(msg.data.status.id),
// data: msg.data.status,
// eventId: event.id
// })
// },
// error(err) {
// console.log('error ', err)
// }
// }
// setTimeout(botController.initialize, 5000)
// module.exports = botController
server/api/index.js
View file @
0eb41a1e
...
...
@@ -14,7 +14,7 @@ const settingsController = require('./controller/settings')
const
storage
=
require
(
'
./storage
'
)
const
upload
=
multer
({
storage
})
const
api
=
express
()
const
api
=
express
.
Router
()
api
.
use
(
cookieParser
())
api
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}))
api
.
use
(
bodyParser
.
json
())
...
...
@@ -100,15 +100,5 @@ api.get('/export/:type', exportController.export)
// get events in this range
api
.
get
(
'
/event/:month/:year
'
,
eventController
.
getAll
)
// Handle 404
api
.
use
(
function
(
req
,
res
)
{
res
.
status
(
404
).
send
(
'
404: Page not Found
'
)
})
// Handle 500
api
.
use
(
function
(
error
,
req
,
res
,
next
)
{
res
.
status
(
500
).
send
(
'
500: Internal Server Error
'
)
})
module
.
exports
=
api
server/emails/confirm/html.pug
View file @
0eb41a1e
...
...
@@ -6,7 +6,7 @@ html(lang="en")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title #{config.title}
body
p= t('email.confirm')
p= t('email.confirm'
, { config }
)
hr
<a
href=
"#{config.baseurl}"
>
#{config.title} - #{config.description}
</a>
\ No newline at end of file
<a
href=
"#{config.baseurl}"
>
#{config.title} - #{config.description}
</a>
server/emails/recover/html.pug
View file @
0eb41a1e
...
...
@@ -6,7 +6,7 @@ html(lang="en")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title #{config.title}
body
p= t('email.recover')
p= t('email.recover'
, {config}
)
hr
<a
href=
"#{config.baseurl}/recover/#{user.recover_code}"
>
#{t('email.press_here')}
</a>
server/federation/index.js
View file @
0eb41a1e
...
...
@@ -21,7 +21,6 @@ router.get('/m/:event_id', async (req, res) => {
const
event_id
=
req
.
params
.
event_id
if
(
req
.
accepts
(
'
html
'
))
return
res
.
redirect
(
301
,
`/event/
${
event_id
}
`
)
console
.
error
(
'
Not asked for html!
'
)
const
event
=
await
Event
.
findByPk
(
req
.
params
.
event_id
,
{
include
:
[
User
]
})
if
(
!
event
)
return
res
.
status
(
404
).
send
(
'
Not found
'
)
return
res
.
json
(
event
.
toAP
(
event
.
user
.
username
))
...
...
server/federation/users.js
View file @
0eb41a1e
...
...
@@ -58,7 +58,6 @@ module.exports = {
where
:
{
username
:
name
}
})
if
(
!
user
)
return
res
.
status
(
404
).
send
(
`No record found for
${
name
}
`
)
console
.
error
(
'
Inside outbox, should return all events from this user
'
)
...
...
@@ -68,9 +67,7 @@ module.exports = {
'
@context
'
:
'
https://www.w3.org/ns/activitystreams
'
,
id
:
`
${
config
.
baseurl
}
/federation/u/
${
name
}
/outbox`
,
type
:
'
OrderedCollection
'
,
// summary: `${user.username} outbox`,
totalItems
:
user
.
events
.
length
,
// orderedItems: user.events.map(e => e.toAP(user.username))
first
:
{
id
:
`
${
config
.
baseurl
}
/federation/u/
${
name
}
/outbox?page=true`
,
type
:
'
OrderedCollectionPage
'
,
...
...
@@ -78,7 +75,6 @@ module.exports = {
partOf
:
`
${
config
.
baseurl
}
/federation/u/
${
name
}
/outbox`
,
orderedItems
:
user
.
events
.
map
(
e
=>
e
.
toAP
(
user
.
username
))
}
// last: `${config.baseurl}/federation/u/${name}/outbox?page=true`
}
res
.
type
(
'
application/activity+json; charset=utf-8
'
)
return
res
.
json
(
ret
)
...
...
server/federation/webfinger.js
View file @
0eb41a1e
...
...
@@ -94,6 +94,14 @@ router.get('/nodeinfo', async (req, res) => {
})
router
.
use
(
'
/host-meta
'
,
(
req
,
res
)
=>
{
res
.
type
(
'
application/xml
'
)
res
.
send
(
`<?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" type="application/xrd+xml" template="
${
config
.
baseurl
}
/.well-known/webfinger?resource={uri}"/>
</XRD>`
)
})
// Handle 404
router
.
use
(
function
(
req
,
res
)
{
res
.
status
(
404
).
send
(
'
404: Page not Found
'
)
...
...
server/index.js
View file @
0eb41a1e
//#!/bin/env node
const
{
Nuxt
,
Builder
}
=
require
(
'
nuxt
'
)
// Import and Set Nuxt.js options
...
...
@@ -22,7 +21,9 @@ async function main() {
// close connections/port/unix socket
function
shutdown
()
{
nuxt
.
close
(()
=>
{
nuxt
.
close
(
async
()
=>
{
const
db
=
require
(
'
./api/models
'
)
await
db
.
sequelize
.
close
()
process
.
exit
()
})
}
...
...
server/notifier.js
View file @
0eb41a1e
const
mail
=
require
(
'
./api/mail
'
)
const
bot
=
require
(
'
./api/controller/fediverse
'
)
//
const bot = require('./api/controller/fediverse')
const
settingsController
=
require
(
'
./api/controller/settings
'
)
const
config
=
require
(
'
config
'
)
const
eventController
=
require
(
'
./api/controller/event
'
)
...
...
@@ -17,17 +17,17 @@ const notifier = {
return
mail
.
send
(
notification
.
email
,
'
event
'
,
{
event
,
config
,
notification
})
case
'
admin_email
'
:
return
mail
.
send
([
config
.
smtp
.
auth
.
user
,
config
.
admin_email
],
'
event
'
,
{
event
,
to_confirm
:
!
event
.
is_visible
,
config
,
notification
})
case
'
mastodon
'
:
// instance publish
if
(
bot
.
bot
)
{
const
b
=
bot
.
post
(
event
).
then
(
b
=>
{
event
.
activitypub_id
=
String
(
b
.
data
.
id
)
return
event
.
save
()
}).
catch
(
e
=>
{
console
.
error
(
"
ERROR !!
"
,
e
)
})
promises
.
push
(
b
)
}
//
case 'mastodon':
//
// instance publish
//
if (bot.bot) {
//
const b = bot.post(event).then(b => {
//
event.activitypub_id = String(b.data.id)
//
return event.save()
//
}).catch(e => {
//
console.error("ERROR !! ", e)
//
})
//
promises.push(b)
//
}
}
return
Promise
.
all
(
promises
)
},
...
...
server/routes.js
View file @
0eb41a1e
...
...
@@ -4,6 +4,7 @@ const express = require('express')
const
api
=
require
(
'
./api
'
)
const
federation
=
require
(
'
./federation
'
)
const
webfinger
=
require
(
'
./federation/webfinger
'
)
const
debug
=
require
(
'
debug
'
)(
'
routes
'
)
const
router
=
express
.
Router
()
router
.
use
(
'
/favicon.ico
'
,
express
.
static
(
path
.
resolve
(
config
.
favicon
||
'
assets/favicon.ico
'
)))
...
...
@@ -14,4 +15,18 @@ router.use('/api', api)
router
.
use
(
'
/.well-known
'
,
webfinger
)
router
.
use
(
'
/federation
'
,
federation
)
// ignore unimplemented ping url from fediverse
router
.
use
(
'
/poco
'
,
(
req
,
res
)
=>
res
.
status
(
404
).
send
(
'
404: Page not found
'
))
// Handle 404
// router.use((req, res) => res.status(404).send('404: Page not found'))
// Handle 500
router
.
use
((
error
,
req
,
res
,
next
)
=>
{
debug
(
'
Error 500: %s
'
,
error
)
res
.
status
(
500
).
send
(
'
500: Internal Server Error
'
)
})
module
.
exports
=
router
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment