Hybrid mode for non resolvable contacts
This commit is contained in:
parent
5d34a90d67
commit
0f2215bc17
2 changed files with 17 additions and 9 deletions
|
@ -23,7 +23,7 @@ namespace Friendica\Model;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Tag
|
* Class Tag
|
||||||
|
@ -69,6 +69,9 @@ class Tag
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cid = 0;
|
||||||
|
$tagid = 0;
|
||||||
|
|
||||||
if (in_array($type, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION])) {
|
if (in_array($type, [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION])) {
|
||||||
if (empty($url)) {
|
if (empty($url)) {
|
||||||
// No mention without a contact url
|
// No mention without a contact url
|
||||||
|
@ -77,13 +80,18 @@ class Tag
|
||||||
|
|
||||||
Logger::info('Get ID for contact', ['url' => $url]);
|
Logger::info('Get ID for contact', ['url' => $url]);
|
||||||
|
|
||||||
$cid = Contact::getIdForURL($url, 0, true);
|
$condition = ['nurl' => Strings::normaliseLink($url), 'uid' => 0, 'deleted' => false];
|
||||||
if (empty($cid)) {
|
$contact = DBA::selectFirst('contact', ['id'], $condition, ['order' => ['id']]);
|
||||||
Logger::error('No contact found', ['url' => $url]);
|
if (DBA::isResult($contact)) {
|
||||||
return;
|
$cid = $contact['id'];
|
||||||
|
} else {
|
||||||
|
// The contact wasn't found in the system (most likely some dead account)
|
||||||
|
// We ensure that we only store a single entry by overwriting the previous name
|
||||||
|
DBA::update('tag', ['name' => substr($name, 0, 96)], ['url' => $url]);
|
||||||
}
|
}
|
||||||
$tagid = 0;
|
}
|
||||||
} else {
|
|
||||||
|
if (empty($cid)) {
|
||||||
$fields = ['name' => substr($name, 0, 96)];
|
$fields = ['name' => substr($name, 0, 96)];
|
||||||
|
|
||||||
if (!empty($url) && ($url != $name)) {
|
if (!empty($url) && ($url != $name)) {
|
||||||
|
@ -102,7 +110,6 @@ class Tag
|
||||||
Logger::error('No tag id created', $fields);
|
Logger::error('No tag id created', $fields);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$cid = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::insert('post-tag', ['uri-id' => $uriid, 'type' => $type, 'tid' => $tagid, 'cid' => $cid], true);
|
DBA::insert('post-tag', ['uri-id' => $uriid, 'type' => $type, 'tid' => $tagid, 'cid' => $cid], true);
|
||||||
|
|
|
@ -1301,7 +1301,8 @@ return [
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
"PRIMARY" => ["id"],
|
"PRIMARY" => ["id"],
|
||||||
"type_name_url" => ["UNIQUE", "name", "url"]
|
"type_name_url" => ["UNIQUE", "name", "url"],
|
||||||
|
"url" => ["url"]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"post-tag" => [
|
"post-tag" => [
|
||||||
|
|
Loading…
Reference in a new issue