xmpp: Make URL removal configurable

This commit is contained in:
PapaTutuWawa 2021-09-19 13:10:27 +02:00
parent a718ab6f86
commit 7b0e1f7e8c
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,11 @@ muc_mention_compat = true
# will leave the MUC.
dont_ignore_offline = true
# If true, when receiving a file to embed in Discord, the bridge will remove the URL from
# the content, leaving only the embed behind. This prevents Discord users who disabled
# link previews from viewing the embed.
remove_url_on_embed = true
# When sending files from Discord to XMPP, proxy the URLS with this template. "<hmac>" and
# and "<url>" will be substituted. Proxy will not be used if not set.
proxy_discord_urls_to = "https://proxy.server.example/proxy/<hmac>/<urls>"

View File

@ -58,6 +58,7 @@ class BridgeComponent(ComponentXMPP):
self._dont_ignore_offline = self._config["general"].get("dont_ignore_offline", True)
self._reactions_compat = self._config["general"].get("reactions_compat", True)
self._muc_mention_compat = self._config["general"].get("muc_mention_compat", True)
self._remove_url_on_embed = self._config["general"].get("remove_url_on_embed", False)
register_stanza_plugin(Message, OOBData)
@ -260,7 +261,7 @@ class BridgeComponent(ComponentXMPP):
embed.set_image(url=message["oob"]["url"])
# I mean, this should always be true, but you never know
if content == message["oob"]["url"]:
if content == message["oob"]["url"] and self._remove_url_on_embed:
# NOTE: To prevent the URL being visible in Discord, remove the content.
# Makes it feel more native.
content = None