Restrict unfurl description to `message_limit` setting

This commit is contained in:
JC Brand 2021-03-02 10:41:24 +01:00
parent 8dd8c7d1dd
commit 1bd4572957
2 changed files with 7 additions and 1 deletions

View File

@ -127,10 +127,15 @@ export function getOpenGraphMetadata (stanza) {
const applies_to_id = fastening.getAttribute('id');
const meta = sizzle(`> meta[xmlns="${Strophe.NS.XHTML}"]`, fastening);
if (meta.length) {
const msg_limit = api.settings.get('message_limit');
const data = meta.reduce((acc, el) => {
const property = el.getAttribute('property');
if (property) {
acc[property] = decodeHTMLEntities(el.getAttribute('content') || '');
let value = decodeHTMLEntities(el.getAttribute('content') || '');
if (msg_limit && property === 'og:description' && value.length >= msg_limit) {
value = `${value.slice(0, msg_limit)}${decodeHTMLEntities('…')}`;
}
acc[property] = value;
}
return acc;
}, {

View File

@ -26,6 +26,7 @@
auto_away: 300,
auto_register_muc_nickname: true,
loglevel: 'debug',
message_limit: 300,
modtools_disable_assign: ['owner', 'moderator', 'participant', 'visitor'],
modtools_disable_query: ['moderator', 'participant', 'visitor'],
enable_smacks: true,