From cb88720bd3e13d0234fd663c8c86cfd6e2367879 Mon Sep 17 00:00:00 2001 From: les Date: Fri, 5 Mar 2021 14:33:33 +0100 Subject: [PATCH] experimenting with AP --- locales/it.json | 1 + server/api/models/event.js | 23 ++++++++++++++--------- server/routes.js | 1 - 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/locales/it.json b/locales/it.json index 755ec065..e88a9ad4 100644 --- a/locales/it.json +++ b/locales/it.json @@ -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. ", diff --git a/server/api/models/event.js b/server/api/models/event.js index deaa5878..a59b23b3 100644 --- a/server/api/models/event.js +++ b/server/api/models/event.js @@ -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}

📍 ${this.place && this.place.name}
@@ -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 } } diff --git a/server/routes.js b/server/routes.js index 2b7aae19..34ef3cab 100644 --- a/server/routes.js +++ b/server/routes.js @@ -1,4 +1,3 @@ -const path = require('path') const config = require('config') const express = require('express') const cors = require('cors')