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
fdb16206
Commit
fdb16206
authored
Aug 10, 2019
by
les
Browse files
send emails with less spam points
parent
f722187c
Changes
10
Hide whitespace changes
Inline
Side-by-side
locales/email/it.json
View file @
fdb16206
...
...
@@ -2,8 +2,9 @@
"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.recover.subject"
:
"Recupero password"
,
"email.recover"
:
"Ciao, hai richiesto un recupero della password su gancio."
,
"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>."
}
\ No newline at end of file
}
nuxt.config.js
View file @
fdb16206
...
...
@@ -13,9 +13,6 @@ module.exports = {
link
:
[{
rel
:
'
icon
'
,
type
:
'
image/x-icon
'
,
href
:
'
/favicon.ico
'
}]
},
dev
:
(
process
.
env
.
NODE_ENV
!==
'
production
'
),
//serverMiddleware: [
//{ path: '/api', handler: '~/server/api/index.js' }
//],
server
:
conf
.
server
,
...
...
@@ -41,7 +38,7 @@ module.exports = {
'
@/plugins/filters
'
,
// text filters, datetime, etc.
'
@/plugins/vue-awesome
'
,
// icon
'
@/plugins/axios
'
,
// axios baseurl configuration
{
src
:
'
@/plugins/v-calendar
'
,
ssr
:
false
},
// calendar,
TO-REDO
{
src
:
'
@/plugins/v-calendar
'
,
ssr
:
false
},
// calendar,
fix ssr
'
@/plugins/i18n.js
'
],
...
...
@@ -82,17 +79,17 @@ module.exports = {
** Build configuration
*/
build
:
{
//
optimization: {
//
splitChunks: {
//
cacheGroups: {
//
element: {
//
test: /[\\/]node_modules[\\/](element-ui)[\\/]/,
//
name: 'element-ui',
//
chunks: 'all'
//
}
//
}
//
}
//
},
optimization
:
{
splitChunks
:
{
cacheGroups
:
{
element
:
{
test
:
/
[\\/]
node_modules
[\\/](
element-ui
)[\\/]
/
,
name
:
'
element-ui
'
,
chunks
:
'
all
'
}
}
}
},
transpile
:
[
/^element-ui/
,
/^vue-awesome/
],
splitChunks
:
{
layouts
:
true
...
...
package.json
View file @
fdb16206
...
...
@@ -5,7 +5,7 @@
"author"
:
"lesion"
,
"scripts"
:
{
"dev:nuxt"
:
"cross-env NODE_ENV=development nuxt dev"
,
"dev"
:
"cross-env DEBUG=fediverse:* NODE_ENV=development n
odemon server/index.js --watch server
"
,
"dev"
:
"cross-env DEBUG=fediverse:* NODE_ENV=development n
uxt
"
,
"build"
:
"nuxt build"
,
"start"
:
"cross-env sequelize db:migrate && NODE_ENV=production node server/cli.js"
,
"lint"
:
"eslint --ext .js,.vue --ignore-path .gitignore ."
,
...
...
server/api/controller/user.js
View file @
fdb16206
...
...
@@ -58,8 +58,10 @@ const userController = {
const
old_path
=
path
.
join
(
config
.
upload_path
,
event
.
image_path
)
const
old_thumb_path
=
path
.
join
(
config
.
upload_path
,
'
thumb
'
,
event
.
image_path
)
try
{
await
fs
.
unlink
(
old_path
)
await
fs
.
unlink
(
old_thumb_path
)
console
.
error
(
'
media files not removed
'
)
// TOFIX
// await fs.unlink(old_path)
// await fs.unlink(old_thumb_path)
}
catch
(
e
)
{
console
.
error
(
e
)
}
...
...
@@ -125,7 +127,7 @@ const userController = {
if
(
req
.
user
)
federation
.
sendEvent
(
event
,
req
.
user
)
res
.
json
(
200
)
//
res.
sendStatus
(200)
// send notification (mastodon/email/confirmation)
// notifier.notifyEvent(event.id)
...
...
server/emails/recover/html.pug
View file @
fdb16206
p= t('email.recover')
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title #{config.title}
body
p= t('email.recover')
<a href="#{config.baseurl}/recover/#{user.recover_code}">#{t('email.press_here')}</a>
\ No newline at end of file
hr
<a
href=
"#{config.baseurl}/recover/#{user.recover_code}"
>
#{t('email.press_here')}
</a>
server/emails/recover/subject.pug
View file @
fdb16206
= `[
Gancio] Richiesta password
recover
y
`
= `[
#{config.title}] ${t('email.
recover
')}
`
server/emails/user_confirm/html.pug
View file @
fdb16206
p !{t('email.user_confirm', { config, user })}
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(http-equiv="X-UA-Compatible", content="ie=edge")
title #{config.title}
body
p !{t('email.user_confirm', { config, user })}
server/federation/comments.js
View file @
fdb16206
...
...
@@ -4,15 +4,21 @@ const debug = require('debug')('fediverse:comment')
module
.
exports
=
{
async
create
(
req
,
res
)
{
const
body
=
req
.
body
//search for related event
const
inReplyTo
=
body
.
object
.
inReplyTo
const
match
=
inReplyTo
.
match
(
`
${
config
.
baseurl
}
/federation/m/(.*)`
)
if
(
!
match
||
match
.
length
<
2
)
return
res
.
status
(
404
).
send
(
'
Event not found!
'
)
cons
t
event
=
await
Event
.
findByPk
(
Number
(
match
[
1
]))
le
t
event
=
await
Event
.
findByPk
(
Number
(
match
[
1
]))
if
(
!
event
)
return
res
.
status
(
404
).
send
(
'
Event not found!
'
)
debug
(
'
comment from %s to %s
'
,
req
.
body
.
actor
,
event
.
titles
)
debug
(
'
comment coming for %s
'
,
inReplyTo
)
if
(
!
event
)
{
// in reply to another comment...
const
comment
=
await
Comment
.
findByPk
(
inReplyTo
,
{
include
:
[
Event
]
})
if
(
!
comment
)
return
res
.
status
(
404
).
send
(
'
Not found
'
)
event
=
comment
.
event
}
debug
(
'
comment from %s to "%s"
'
,
req
.
body
.
actor
,
event
.
title
)
await
Comment
.
create
({
activitypub_id
:
body
.
object
.
id
,
...
...
server/federation/helpers.js
View file @
fdb16206
const
fetch
=
require
(
'
node-fetch
'
)
const
request
=
require
(
'
request
'
)
//
const request = require('request')
const
crypto
=
require
(
'
crypto
'
)
const
config
=
require
(
'
config
'
)
const
httpSignature
=
require
(
'
http-signature
'
)
...
...
@@ -29,29 +29,23 @@ const Helpers = {
console
.
error
(
'
header
'
,
header
)
console
.
error
(
'
requestTo
'
,
toInbox
)
console
.
error
(
'
host
'
,
toOrigin
.
hostname
)
request
({
url
:
toInbox
,
const
response
=
await
fetch
(
toInbox
,
{
headers
:
{
'
Host
'
:
toOrigin
.
hostname
,
'
Date
'
:
d
.
toUTCString
(),
'
Signature
'
:
header
,
'
Content-Type
'
:
'
application/activity+json; charset=utf-8
'
'
Content-Type
'
:
'
application/activity+json; charset=utf-8
'
,
'
Accept
'
:
'
application/activity+json, application/json; chartset=utf-8
'
},
method
:
'
POST
'
,
json
:
true
,
body
:
message
},
function
(
error
,
response
){
if
(
error
)
{
console
.
log
(
'
Error:
'
,
error
,
response
.
body
)
}
else
{
console
.
log
(
'
Response:
'
,
response
.
body
,
response
.
statusCode
,
response
.
status
,
response
.
statusMessage
)
}
})
body
:
JSON
.
stringify
(
message
)
})
console
.
log
(
'
Response:
'
,
response
.
body
,
response
.
statusCode
,
response
.
status
,
response
.
statusMessage
)
},
async
sendEvent
(
event
,
user
)
{
const
followers
=
user
.
followers
for
(
let
follower
of
followers
)
{
debug
(
'
Notify %s with event %s
'
,
follower
,
event
.
title
)
const
body
=
event
.
toAP
(
user
.
username
,
follower
)
body
[
'
@context
'
]
=
'
https://www.w3.org/ns/activitystreams
'
Helpers
.
signAndSend
(
body
,
user
,
follower
)
...
...
server/federation/index.js
View file @
fdb16206
...
...
@@ -38,7 +38,7 @@ router.post('/u/:name/inbox', Helpers.verifySignature, async (req, res) => {
Follows
.
follow
(
req
,
res
)
break
case
'
Undo
'
:
// unfollow || unlike
// unfollow || unlike
|| unboost
if
(
b
.
object
.
type
===
'
Follow
'
)
{
Follows
.
unfollow
(
req
,
res
)
}
else
if
(
b
.
object
.
type
===
'
Like
'
)
{
...
...
Write
Preview
Supports
Markdown
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