From 3613ba714878f8503d590bb24423572d1bc54ee7 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 10 Jul 2021 14:51:12 +0200 Subject: Initial commit, the start of an unshorturl addon. --- unshorturl/unshorturl.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 unshorturl/unshorturl.php (limited to 'unshorturl/unshorturl.php') diff --git a/unshorturl/unshorturl.php b/unshorturl/unshorturl.php new file mode 100644 index 0000000..626891f --- /dev/null +++ b/unshorturl/unshorturl.php @@ -0,0 +1,31 @@ + + * Maintainer: Harald Eilertsen + * + * SPDX-FileCopyrightText: 2021 Harald Eilertsen + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +use Zotlabs\Lib\Apps; +use Zotlabs\Extend\Hooks; + +function unshorturl_install() { + Hook::register('perpare_body', 'addon/unshorturl/unshorturl.php', 'unshorturl_prepare_body', 1); +} + +function unshorturl_uninstall() { + Hook::deregister('prepare_body', 'addon/unshorturl/unshorturl.php', 'unshorturl_prepare_body'); +} + +function unshorturl_prepare_body(&$body) { + if (!local_channel() || !Apps::addon_app_installed(local_channel(), 'unshorturl')) { + return; + } + + preg_replace('/https?:\/\/bit.ly\/[^\s]+/g', '[hidden bitly link]'); +} -- cgit v1.2.3