Merge pull request #1061 from annando/issue-9692

Twitter Issue 9692: Only append Twitter profile links as mentions
This commit is contained in:
Hypolite Petovan 2020-12-24 12:02:26 -05:00 committed by GitHub
commit 7ce00592a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -557,7 +557,7 @@ function twitter_post_hook(App $a, array &$b)
}
$condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]];
$orig_post = Item::selectFirst([], $condition);
$orig_post = Item::selectFirst(['author-nick', 'author-network'], $condition);
if (!DBA::isResult($orig_post)) {
Logger::warning('No parent found', ['thr-parent' => $b["thr-parent"]]);
return;
@ -565,15 +565,15 @@ function twitter_post_hook(App $a, array &$b)
$iscomment = true;
}
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]";
$nicknameplain = "@" . $nicknameplain;
if ($orig_post['author-network'] == Protocol::TWITTER) {
$nickname = "@[url=" . $orig_post["author-link"] . "]" . $orig_post["author-nick"] . "[/url]";
$nicknameplain = "@" . $orig_post["author-nick"];
Logger::info('Comparing', ['nickname' => $nickname, 'nicknameplain' => $nicknameplain, 'body' => $b["body"]]);
if ((strpos($b["body"], $nickname) === false) && (strpos($b["body"], $nicknameplain) === false)) {
$b["body"] = $nickname . " " . $b["body"];
}
}
Logger::debug('Parent found', ['parent' => $orig_post]);
} else {