Merge pull request #5086 from annando/issue-2880

Issue 2880: Editing post doesn't destroy mentions or hashtags anymore
This commit is contained in:
Hypolite Petovan 2018-05-19 12:01:05 -04:00 committed by GitHub
commit d4ebf7ae52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View file

@ -14,6 +14,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
@ -1965,6 +1966,10 @@ function undo_post_tagging($s) {
$cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER); $cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER);
if ($cnt) { if ($cnt) {
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
if (in_array($mtch[1], ['!', '@'])) {
$contact = Contact::getDetailsByURL($mtch[2]);
$mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
}
$s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s); $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
} }
} }

View file

@ -661,6 +661,11 @@ function item_post(App $a) {
$datarray['edit'] = true; $datarray['edit'] = true;
} }
// Check for hashtags in the body and repair or add hashtag links
if ($preview || $orig_post) {
Item::setHashtags($datarray);
}
// preview mode - prepare the body for display and send it via json // preview mode - prepare the body for display and send it via json
if ($preview) { if ($preview) {
require_once 'include/conversation.php'; require_once 'include/conversation.php';

View file

@ -1250,7 +1250,7 @@ class Item extends BaseObject
} }
} }
private static function setHashtags(&$item) public static function setHashtags(&$item)
{ {
$tags = get_tags($item["body"]); $tags = get_tags($item["body"]);