Files
opencloud/services/groupware/apidoc-postprocess-html.js
Pascal Bleser 91e2705bb1 groupware: omit "position" when "anchor" is specified in queries
* the "position" attribute is always set to 0 when using an anchor for
   pagination, but it does not accurately reflect the position and thus
   we decided to remove the attribute from the resulting object for
   clarity

 * omit "canCalculateChanges" attribute when its value is "true", which
   is going to be the case in 100% of calls against Stalwart
2026-04-30 10:51:45 +02:00

39 lines
923 B
JavaScript

import * as fs from 'fs'
import * as cheerio from 'cheerio'
import { stdin } from 'process'
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
process.exit(1);
});
async function run() {
try {
const faviconFile = process.argv[2];
if (!faviconFile) {
throw new Error("No favicon file provided");
}
const favicon = fs.readFileSync(faviconFile).toString('base64');
let html = '';
for await (const chunk of stdin) {
html += chunk;
}
if (!html) {
throw new Error("No HTML received from stdin");
}
const $ = cheerio.load(html);
$('head').append(`<link rel="icon" href="data:image/png;base64,${favicon}">`);
process.stdout.write($.html() + "\n");
} catch (e) {
console.error(`Error occurred while post-processing HTML: ${e.message}`);
process.exit(1);
}
}
run();