From 1b43d459b68af499c09db860b05d4d13d83d98c9 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Thu, 1 Nov 2018 23:52:06 +0000
Subject: [PATCH] Fix for delivering forum posts again

---
 mod/item.php       |  6 ++++++
 src/Model/Term.php | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/mod/item.php b/mod/item.php
index 54ef53a4b8..739e09ab0f 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -839,6 +839,12 @@ function item_post(App $a) {
 	// We don't fork a new process since this is done anyway with the following command
 	Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "CreateShadowEntry", $post_id);
 
+	// When we are doing some forum posting via ! we have to start the notifier manually.
+	// These kind of posts don't initiate the notifier call in the item class.
+	if ($only_to_forum) {
+		Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
+	}
+
 	Logger::log('post_complete');
 
 	if ($api_source) {
diff --git a/src/Model/Term.php b/src/Model/Term.php
index f62fced709..2870eb167d 100644
--- a/src/Model/Term.php
+++ b/src/Model/Term.php
@@ -86,7 +86,7 @@ class Term
 
 		$tags_string = '';
 		foreach ($taglist as $tag) {
-			if ((substr(trim($tag), 0, 1) == '#') || (substr(trim($tag), 0, 1) == '@')) {
+			if ((substr(trim($tag), 0, 1) == '#') || (substr(trim($tag), 0, 1) == '@') || (substr(trim($tag), 0, 1) == '!')) {
 				$tags_string .= ' ' . trim($tag);
 			} else {
 				$tags_string .= ' #' . trim($tag);
@@ -107,11 +107,11 @@ class Term
 			}
 		}
 
-		$pattern = '/\W([\#@])\[url\=(.*?)\](.*?)\[\/url\]/ism';
+		$pattern = '/\W([\#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism';
 		if (preg_match_all($pattern, $data, $matches, PREG_SET_ORDER)) {
 			foreach ($matches as $match) {
 
-				if ($match[1] == '@') {
+				if (($match[1] == '@') || ($match[1] == '!')) {
 					$contact = Contact::getDetailsByURL($match[2], 0);
 					if (!empty($contact['addr'])) {
 						$match[3] = $contact['addr'];
@@ -140,7 +140,7 @@ class Term
 
 				$type = TERM_HASHTAG;
 				$term = substr($tag, 1);
-			} elseif (substr(trim($tag), 0, 1) == '@') {
+			} elseif ((substr(trim($tag), 0, 1) == '@') || (substr(trim($tag), 0, 1) == '!')) {
 				$type = TERM_MENTION;
 
 				$contact = Contact::getDetailsByURL($link, 0);
@@ -179,7 +179,7 @@ class Term
 			]);
 
 			// Search for mentions
-			if ((substr($tag, 0, 1) == '@') && (strpos($link, $profile_base_friendica) || strpos($link, $profile_base_diaspora))) {
+			if (((substr($tag, 0, 1) == '@') || (substr($tag, 0, 1) == '!')) && (strpos($link, $profile_base_friendica) || strpos($link, $profile_base_diaspora))) {
 				$users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link);
 				foreach ($users AS $user) {
 					if ($user['uid'] == $message['uid']) {
-- 
2.39.5