fix: include description into rss/ics

This commit is contained in:
lesion 2024-01-08 22:55:33 +01:00
parent 07a0ea0146
commit 4f99a5df30
No known key found for this signature in database
GPG key ID: 352918250B012177
4 changed files with 11 additions and 11 deletions

View file

@ -4,7 +4,6 @@ const log = require('../../log')
const { DateTime } = require('luxon')
const { col: Col, queryParamToBool } = require('../../helpers')
const { Op, Sequelize } = require('sequelize')
const { getActor, followActor, unfollowActor } = require('../../federation/helpers')
const exportController = require('./export')
const collectionController = {
@ -68,7 +67,7 @@ const collectionController = {
},
// return events from collection
async _getEvents ({ name, start, end, limit }) {
async _getEvents ({ name, start, end, limit, include_description=false }) {
const collection = await Collection.findOne({ where: { name } })
if (!collection) {
@ -130,7 +129,7 @@ const collectionController = {
const events = await Event.findAll({
where,
attributes: {
exclude: ['likes', 'boost', 'userId', 'is_visible', 'createdAt', 'description', 'resources', 'ap_id']
exclude: ['likes', 'boost', 'userId', 'is_visible', 'createdAt', 'resources', 'ap_id', ...(!include_description && ['description'])]
},
order: ['start_datetime'],
include: [
@ -198,10 +197,10 @@ const collectionController = {
const { collectionId, tags, places, actors } = req.body
try {
if (actors?.length) {
const actors_to_follow = await APUser.findAll({ where: { ap_id: { [Op.in]: actors.map(a => a.ap_id) }} })
await Promise.all(actors_to_follow.map(followActor))
}
// if (actors?.length) {
// const actors_to_follow = await APUser.findAll({ where: { ap_id: { [Op.in]: actors.map(a => a.ap_id) }} })
// await Promise.all(actors_to_follow.map(followActor))
// }
const filter = await Filter.create({ collectionId, tags, places, actors })
return res.json(filter)
} catch (e) {

View file

@ -613,7 +613,8 @@ const eventController = {
limit,
page,
older,
reverse }) {
reverse,
include_description=false }) {
const where = {
// do not include _parent_ recurrent event
@ -687,7 +688,7 @@ const eventController = {
const events = await Event.findAll({
where,
attributes: {
exclude: ['likes', 'boost', 'userId', 'is_visible', 'createdAt', 'description', 'resources', 'recurrent', 'placeId', 'image_path']
exclude: ['likes', 'boost', 'userId', 'is_visible', 'createdAt', 'resources', 'recurrent', 'placeId', 'image_path', ...(!include_description && ['description'])]
},
order: [['start_datetime', reverse ? 'DESC' : 'ASC']],
include: [

View file

@ -18,7 +18,7 @@ module.exports = {
const format = req.params.format || 'json'
log.debug(`Events for place: ${placeName}`)
const events = await eventController._select({ places: String(place.id), show_recurrent: true, show_multidate: true, reverse: true, start: 0 })
const events = await eventController._select({ places: String(place.id), show_recurrent: true, show_multidate: true, reverse: true, start: 0, include_description: true })
switch (format) {
case 'rss':

View file

@ -41,7 +41,7 @@ module.exports = {
Sequelize.Op.eq, tags.toLocaleLowerCase())})) {
return res.sendStatus(404)
}
const events = await eventController._select({ tags: tags.toLocaleLowerCase(), show_recurrent: true, show_multidate: true, start: 0, reverse: true })
const events = await eventController._select({ tags: tags.toLocaleLowerCase(), show_recurrent: true, show_multidate: true, start: 0, reverse: true, include_description: true })
switch (format) {
case 'rss':
return exportController.feed(req, res, events,