efafc2d691
even if the global configuration is to disallow it. * When parsing, include all media URLs, not just the ones from allowed domains. That makes it possible to change allowed domains on-the-fly, while still allowing media in individual messages to be shown manually (via the message actions dropdown). * Merge `embed_audio`, `embed_video` and `show_images_inline` into `render_media` * Create new config settings for allowable domains for images, video and audio * Check the URL domain against a whitelist for the message actions dropdown
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import Storage from '@converse/skeletor/src/storage.js';
|
|
import { _converse, api } from '@converse/headless/core';
|
|
|
|
export function getDefaultStore () {
|
|
if (_converse.config.get('trusted')) {
|
|
const is_non_persistent = api.settings.get('persistent_store') === 'sessionStorage';
|
|
return is_non_persistent ? 'session': 'persistent';
|
|
} else {
|
|
return 'session';
|
|
}
|
|
}
|
|
|
|
function storeUsesIndexedDB (store) {
|
|
return store === 'persistent' && api.settings.get('persistent_store') === 'IndexedDB';
|
|
}
|
|
|
|
export function createStore (id, store) {
|
|
const name = store || getDefaultStore();
|
|
const s = _converse.storage[name];
|
|
if (typeof s === 'undefined') {
|
|
throw new TypeError(`createStore: Could not find store for ${id}`);
|
|
}
|
|
return new Storage(id, s, storeUsesIndexedDB(store));
|
|
}
|
|
|
|
export function initStorage (model, id, type) {
|
|
const store = type || getDefaultStore();
|
|
model.browserStorage = createStore(id, store);
|
|
if (storeUsesIndexedDB(store)) {
|
|
const flush = () => model.browserStorage.flush();
|
|
window.addEventListener(_converse.unloadevent, flush);
|
|
model.on('destroy', () => window.removeEventListener(_converse.unloadevent, flush));
|
|
model.listenTo(_converse, 'beforeLogout', flush);
|
|
}
|
|
}
|