experimenting with AP

This commit is contained in:
les 2021-03-05 14:33:33 +01:00
parent 076390ba2f
commit cb88720bd3
No known key found for this signature in database
GPG key ID: 352918250B012177
3 changed files with 15 additions and 10 deletions

View file

@ -122,6 +122,7 @@
"tag_description": "Etichetta",
"media_description": "Puoi aggiungere un volantino (opzionale)",
"added": "Evento aggiunto",
"saved": "Evento salvato",
"added_anon": "Evento aggiunto, verrà confermato quanto prima.",
"updated": "Evento aggiornato",
"where_description": "Dov'è il gancio? Se il posto non è presente potrai crearlo. ",

View file

@ -12,6 +12,10 @@ const Place = require('./place')
const User = require('./user')
const Tag = require('./tag')
const utc = require('dayjs/plugin/utc')
const dayjs = require('dayjs')
dayjs.extend(utc)
class Event extends Model {}
Event.init({
@ -59,7 +63,7 @@ Event.belongsTo(Event, { as: 'parent' })
Event.prototype.toAPNote = function (username, locale, to = []) {
const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_'))
const plainDescription = htmlToText.fromString(this.description.replace('\n', '').slice(0, 1000))
const plainDescription = htmlToText.fromString(this.description && this.description.replace('\n', '').slice(0, 1000))
const content = `
${this.title}<br/><br/>
📍 ${this.place && this.place.name}<br/>
@ -94,16 +98,17 @@ Event.prototype.toAPNote = function (username, locale, to = []) {
// name: this.place && this.place.name
// },
// attachment,
tag: tags && tags.map(tag => ({
type: 'Hashtag',
name: '#' + tag,
href: '/tags/' + tag
})),
published: this.createdAt,
// tag: tags && tags.map(tag => ({
// type: 'Hashtag',
// name: '#' + tag,
// href: '/tags/' + tag
// })),
published: dayjs(this.createdAt).utc().format(),
attributedTo: `${config.baseurl}/federation/u/${username}`,
to: 'https://www.w3.org/ns/activitystreams#Public',
// cc: [`${config.baseurl}/federation/u/${username}/followers`],
content
cc: [`${config.baseurl}/federation/u/${username}/followers`],
content,
summary: null
}
}

View file

@ -1,4 +1,3 @@
const path = require('path')
const config = require('config')
const express = require('express')
const cors = require('cors')