Commit cc8d56cf authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Preview: Consider public/private MUCs

parent a9d92037
......@@ -212,7 +212,7 @@ def get_previewable(self, text, additional_data):
return True
def create_preview(self, uri, widget):
def create_preview(self, uri, widget, context):
if uri.startswith('geo:'):
preview = Preview(uri, None, None, None, 96, widget)
preview.update_widget()
......@@ -221,6 +221,12 @@ def create_preview(self, uri, widget):
preview = self._process_web_uri(uri, widget)
if not preview.orig_exists():
if context is not None:
allow_in_public = app.settings.get('preview_anonymous_muc')
if context == 'public' and not allow_in_public:
preview.update_widget()
return
self.download_content(preview)
elif not preview.thumb_exists():
......
......@@ -22,6 +22,7 @@
from gajim.common import app
from gajim.common.const import AvatarSize
from gajim.common.const import TRUST_SYMBOL_DATA
from gajim.common.helpers import get_muc_context
from gajim.common.helpers import reduce_chars_newlines
from gajim.common.helpers import to_user_string
from gajim.common.styling import process
......@@ -75,9 +76,12 @@ def __init__(self,
is_previewable = app.interface.preview_manager.get_previewable(
text, additional_data)
if is_previewable:
context = None
if self._is_groupchat:
context = get_muc_context(self._contact.jid)
self._message_widget = PreviewWidget(account)
app.interface.preview_manager.create_preview(
text, self._message_widget)
text, self._message_widget, context)
else:
result = process(text)
self._message_widget = MessageWidget(account)
......
......@@ -504,6 +504,13 @@ def __init__(self, *args):
desc=_('Maximum file size for preview generation'),
props={'entries': sizes}),
Setting(SettingKind.SWITCH,
_('Preview in Public Group Chats'),
SettingType.CONFIG,
'preview_anonymous_muc',
desc=_('Generate preview automatically in public '
'group chats (may disclose your data)')),
Setting(SettingKind.SWITCH,
_('Preview all Image URLs'),
SettingType.CONFIG,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment