@eeacms/volto-cca-policy 0.3.122 → 0.3.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [0.3.123](https://github.com/eea/volto-cca-policy/compare/0.3.122...0.3.123) - 11 May 2026
|
|
8
|
+
|
|
9
|
+
#### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
- fix: improve error logging [kreafox - [`58bfd70`](https://github.com/eea/volto-cca-policy/commit/58bfd70ce2155de6f8a773b8bcf9482ceb704211)]
|
|
12
|
+
- fix: add error logging in RSS middleware [kreafox - [`048d715`](https://github.com/eea/volto-cca-policy/commit/048d7154a118367a1ce4c6660c71517f8f049d55)]
|
|
13
|
+
- fix: improve image URL resolution [kreafox - [`f3e2e32`](https://github.com/eea/volto-cca-policy/commit/f3e2e323b8d9c9a77e1656c1f2f8a09592733b86)]
|
|
14
|
+
|
|
7
15
|
### [0.3.122](https://github.com/eea/volto-cca-policy/compare/0.3.121...0.3.122) - 8 May 2026
|
|
8
16
|
|
|
9
17
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
|
@@ -33,16 +33,17 @@ import config from '@plone/volto/registry';
|
|
|
33
33
|
* @throws Will throw an error if no query data is found in the listing block or if the request fails.
|
|
34
34
|
*/
|
|
35
35
|
async function getRssFeedData(apiPath, APISUFFIX, req, settings) {
|
|
36
|
-
const
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const url = `${apiPath}${__DEVELOPMENT__ ? '' : APISUFFIX}${req.path.replace(
|
|
37
|
+
'/rss.xml',
|
|
38
|
+
'',
|
|
39
|
+
)}`;
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.error('[RSS] Fetching feed data from:', url);
|
|
43
|
+
|
|
44
|
+
const request = superagent.get(url).accept('json');
|
|
44
45
|
|
|
45
|
-
const authToken = req.universalCookies
|
|
46
|
+
const authToken = req.universalCookies?.get?.('auth_token');
|
|
46
47
|
if (authToken) {
|
|
47
48
|
request.set('Authorization', `Bearer ${authToken}`);
|
|
48
49
|
}
|
|
@@ -174,6 +175,21 @@ function safeDate(value) {
|
|
|
174
175
|
return d;
|
|
175
176
|
}
|
|
176
177
|
|
|
178
|
+
function resolveImageUrl(download, itemUrl, publicURL, apiPath) {
|
|
179
|
+
if (!download || !itemUrl) return undefined;
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const base = itemUrl.endsWith('/') ? itemUrl : `${itemUrl}/`;
|
|
183
|
+
return normalizeFeedURL(
|
|
184
|
+
new URL(download, base).toString(),
|
|
185
|
+
publicURL,
|
|
186
|
+
apiPath,
|
|
187
|
+
);
|
|
188
|
+
} catch {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
177
193
|
/**
|
|
178
194
|
* Creates an Express middleware for generating an RSS feed using the listing block of the
|
|
179
195
|
* rss_feed content type.
|
|
@@ -218,7 +234,7 @@ function make_rssMiddleware() {
|
|
|
218
234
|
query,
|
|
219
235
|
apiPath,
|
|
220
236
|
APISUFFIX,
|
|
221
|
-
req.universalCookies
|
|
237
|
+
req.universalCookies?.get?.('auth_token'),
|
|
222
238
|
);
|
|
223
239
|
const feedOptions = {
|
|
224
240
|
title: truncateText(title, max_title_length),
|
|
@@ -238,20 +254,28 @@ function make_rssMiddleware() {
|
|
|
238
254
|
let enclosure = undefined;
|
|
239
255
|
|
|
240
256
|
const imageData = item.image_scales?.[item.image_field]?.[0];
|
|
241
|
-
const
|
|
257
|
+
const previewScale = imageData?.scales?.preview;
|
|
258
|
+
const imageDownload = previewScale?.download || imageData?.download;
|
|
259
|
+
const imageSize = previewScale?.size || imageData?.size;
|
|
260
|
+
const imageType =
|
|
261
|
+
previewScale?.['content-type'] || imageData?.['content-type'];
|
|
262
|
+
|
|
263
|
+
const imageUrl = resolveImageUrl(
|
|
264
|
+
imageDownload,
|
|
265
|
+
link,
|
|
266
|
+
settings.publicURL,
|
|
267
|
+
apiPath,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const numericImageSize = Number(imageSize);
|
|
242
271
|
|
|
243
|
-
if (
|
|
272
|
+
if (imageUrl && Number.isFinite(numericImageSize) && imageType) {
|
|
244
273
|
enclosure = {
|
|
245
|
-
url:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
apiPath,
|
|
249
|
-
),
|
|
250
|
-
type: imageData['content-type'],
|
|
251
|
-
size: imageData.size,
|
|
274
|
+
url: imageUrl,
|
|
275
|
+
type: imageType,
|
|
276
|
+
size: numericImageSize,
|
|
252
277
|
};
|
|
253
278
|
}
|
|
254
|
-
|
|
255
279
|
feed.item({
|
|
256
280
|
title: truncateText(item.title, max_title_length),
|
|
257
281
|
description: truncateText(
|
|
@@ -271,6 +295,14 @@ function make_rssMiddleware() {
|
|
|
271
295
|
res.setHeader('Content-Type', 'application/rss+xml; charset=utf-8');
|
|
272
296
|
res.send(xml);
|
|
273
297
|
} catch (err) {
|
|
298
|
+
// eslint-disable-next-line no-console
|
|
299
|
+
console.error('[RSS] Failed', {
|
|
300
|
+
path: req.path,
|
|
301
|
+
apiPath,
|
|
302
|
+
APISUFFIX,
|
|
303
|
+
message: err.message,
|
|
304
|
+
stack: err.stack,
|
|
305
|
+
});
|
|
274
306
|
if (err.response && err.response.status === 401) {
|
|
275
307
|
// Handle unauthorized errors
|
|
276
308
|
res.status(401).json({
|