From 975c752ba2ba21a36b2208e62f9ff430d46a4115 Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 19 Jan 2024 00:43:32 +0100 Subject: [PATCH] feat(AP): improve online events format --- server/api/models/event.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/server/api/models/event.js b/server/api/models/event.js index 7427b893..f47678ca 100644 --- a/server/api/models/event.js +++ b/server/api/models/event.js @@ -46,11 +46,21 @@ module.exports = (sequelize, DataTypes) => { zone: settings.instance_timezone, locale: settings.instance_locale } - const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_')) + // const tags = this.tags && this.tags.map(t => t.tag.replace(/[#]/g, '_')) const summary = `${this.place && this.place.name}, ${DateTime.fromSeconds(this.start_datetime, opt).toFormat('EEEE, d MMMM (HH:mm)')}` - const attachment = [] - if (this.media && this.media.length) { + let attachment = [] + + if (this?.online_locations?.length) { + attachment = this.online_locations.map( href => ({ + type: 'Link', + mediaType: 'text/html', + name: href, + href + })) + } + + if (this?.media?.length) { attachment.push({ type: 'Document', mediaType: 'image/jpeg', @@ -59,7 +69,7 @@ module.exports = (sequelize, DataTypes) => { focalPoint: this.media[0].focalPoint || [0, 0] }) } - + return { id: `${config.baseurl}/federation/m/${this.id}`, name: this.title, @@ -75,10 +85,10 @@ module.exports = (sequelize, DataTypes) => { longitude: this.place.longitude }, attachment, - tag: tags && tags.map(tag => ({ + tag: this.tags && this.tags.map(tag => ({ type: 'Hashtag', - name: '#' + tag, - href: `${config.baseurl}/tag/${tag}` + name: '#' + tag.tag, + href: `${config.baseurl}/tag/${tag.tag}` })), published: this.createdAt, attributedTo: `${config.baseurl}/federation/u/${username}`,