send emails with less spam points

This commit is contained in:
les
2019-08-10 15:00:08 +02:00
parent f722187c65
commit fdb1620658
10 changed files with 61 additions and 43 deletions

View File

@@ -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)

View File

@@ -1,3 +1,12 @@
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>
hr
<a href="#{config.baseurl}/recover/#{user.recover_code}">#{t('email.press_here')}</a>

View File

@@ -1 +1 @@
= `[Gancio] Richiesta password recovery`
= `[#{config.title}] ${t('email.recover')}`

View File

@@ -1 +1,10 @@
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 })}

View File

@@ -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!')
const event = await Event.findByPk(Number(match[1]))
let 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,

View File

@@ -1,5 +1,5 @@
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)

View File

@@ -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') {