feat(AP): improve online events format

This commit is contained in:
lesion 2024-01-19 00:43:32 +01:00
parent a46c202ac9
commit 975c752ba2
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -46,11 +46,21 @@ module.exports = (sequelize, DataTypes) => {
zone: settings.instance_timezone, zone: settings.instance_timezone,
locale: settings.instance_locale 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 summary = `${this.place && this.place.name}, ${DateTime.fromSeconds(this.start_datetime, opt).toFormat('EEEE, d MMMM (HH:mm)')}`
const attachment = [] let attachment = []
if (this.media && this.media.length) {
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({ attachment.push({
type: 'Document', type: 'Document',
mediaType: 'image/jpeg', mediaType: 'image/jpeg',
@ -59,7 +69,7 @@ module.exports = (sequelize, DataTypes) => {
focalPoint: this.media[0].focalPoint || [0, 0] focalPoint: this.media[0].focalPoint || [0, 0]
}) })
} }
return { return {
id: `${config.baseurl}/federation/m/${this.id}`, id: `${config.baseurl}/federation/m/${this.id}`,
name: this.title, name: this.title,
@ -75,10 +85,10 @@ module.exports = (sequelize, DataTypes) => {
longitude: this.place.longitude longitude: this.place.longitude
}, },
attachment, attachment,
tag: tags && tags.map(tag => ({ tag: this.tags && this.tags.map(tag => ({
type: 'Hashtag', type: 'Hashtag',
name: '#' + tag, name: '#' + tag.tag,
href: `${config.baseurl}/tag/${tag}` href: `${config.baseurl}/tag/${tag.tag}`
})), })),
published: this.createdAt, published: this.createdAt,
attributedTo: `${config.baseurl}/federation/u/${username}`, attributedTo: `${config.baseurl}/federation/u/${username}`,