Twitter: Assign contacts via their twitter id - not via their url #1234
|
@ -1346,6 +1346,8 @@ function twitter_user_to_contact($data)
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
|
'nurl' => Strings::normaliseLink($url),
|
||||||
|
'uri-id' => ItemURI::getIdByURI($url),
|
||||||
'network' => Protocol::TWITTER,
|
'network' => Protocol::TWITTER,
|
||||||
'alias' => 'twitter::' . $data->id_str,
|
'alias' => 'twitter::' . $data->id_str,
|
||||||
'baseurl' => $baseurl,
|
'baseurl' => $baseurl,
|
||||||
|
@ -1361,6 +1363,16 @@ function twitter_user_to_contact($data)
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function twitter_get_contact($data, int $uid = 0)
|
||||||
|
{
|
||||||
|
$contact = DBA::selectFirst('contact', ['id'], ['uid' => $uid, 'alias' => "twitter::" . $data->id_str]);
|
||||||
|
if (DBA::isResult($contact)) {
|
||||||
|
return $contact['id'];
|
||||||
|
} else {
|
||||||
|
return twitter_fetch_contact($uid, $data, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function twitter_fetch_contact($uid, $data, $create_user)
|
function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
{
|
{
|
||||||
$fields = twitter_user_to_contact($data);
|
$fields = twitter_user_to_contact($data);
|
||||||
|
@ -1402,7 +1414,6 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
// create contact record
|
// create contact record
|
||||||
$fields['uid'] = $uid;
|
$fields['uid'] = $uid;
|
||||||
$fields['created'] = DateTimeFormat::utcNow();
|
$fields['created'] = DateTimeFormat::utcNow();
|
||||||
$fields['nurl'] = Strings::normaliseLink($fields['url']);
|
|
||||||
$fields['poll'] = 'twitter::' . $data->id_str;
|
$fields['poll'] = 'twitter::' . $data->id_str;
|
||||||
$fields['rel'] = $relation;
|
$fields['rel'] = $relation;
|
||||||
$fields['priority'] = 1;
|
$fields['priority'] = 1;
|
||||||
|
@ -1418,8 +1429,6 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
$contact_id = DBA::lastInsertId();
|
$contact_id = DBA::lastInsertId();
|
||||||
|
|
||||||
Group::addMember(User::getDefaultGroup($uid), $contact_id);
|
Group::addMember(User::getDefaultGroup($uid), $contact_id);
|
||||||
|
|
||||||
Contact::updateAvatar($contact_id, $avatar);
|
|
||||||
} else {
|
} else {
|
||||||
if ($contact["readonly"] || $contact["blocked"]) {
|
if ($contact["readonly"] || $contact["blocked"]) {
|
||||||
Logger::notice('Contact is blocked or readonly.', ['nickname' => $contact["nick"]]);
|
Logger::notice('Contact is blocked or readonly.', ['nickname' => $contact["nick"]]);
|
||||||
|
@ -1435,8 +1444,6 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
$update = true;
|
$update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact::updateAvatar($contact['id'], $avatar);
|
|
||||||
|
|
||||||
if ($contact['name'] != $data->name) {
|
if ($contact['name'] != $data->name) {
|
||||||
$fields['name-date'] = $fields['uri-date'] = DateTimeFormat::utcNow();
|
$fields['name-date'] = $fields['uri-date'] = DateTimeFormat::utcNow();
|
||||||
$update = true;
|
$update = true;
|
||||||
|
@ -1458,6 +1465,8 @@ function twitter_fetch_contact($uid, $data, $create_user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Contact::updateAvatar($contact_id, $avatar);
|
||||||
|
|
||||||
return $contact_id;
|
return $contact_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1787,6 +1796,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
|
||||||
if ($contactid == 0) {
|
if ($contactid == 0) {
|
||||||
$contactid = twitter_fetch_contact($uid, $post->user, $create_user);
|
$contactid = twitter_fetch_contact($uid, $post->user, $create_user);
|
||||||
|
|
||||||
|
$postarray['owner-id'] = twitter_get_contact($post->user);
|
||||||
$postarray['owner-name'] = $post->user->name;
|
$postarray['owner-name'] = $post->user->name;
|
||||||
$postarray['owner-link'] = "https://twitter.com/" . $post->user->screen_name;
|
$postarray['owner-link'] = "https://twitter.com/" . $post->user->screen_name;
|
||||||
$postarray['owner-avatar'] = twitter_fix_avatar($post->user->profile_image_url_https);
|
$postarray['owner-avatar'] = twitter_fix_avatar($post->user->profile_image_url_https);
|
||||||
|
@ -1800,8 +1810,8 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
|
||||||
}
|
}
|
||||||
|
|
||||||
$postarray['contact-id'] = $contactid;
|
$postarray['contact-id'] = $contactid;
|
||||||
|
|
||||||
$postarray['verb'] = Activity::POST;
|
$postarray['verb'] = Activity::POST;
|
||||||
|
$postarray['author-id'] = $postarray['owner-id'];
|
||||||
$postarray['author-name'] = $postarray['owner-name'];
|
$postarray['author-name'] = $postarray['owner-name'];
|
||||||
$postarray['author-link'] = $postarray['owner-link'];
|
$postarray['author-link'] = $postarray['owner-link'];
|
||||||
$postarray['author-avatar'] = $postarray['owner-avatar'];
|
$postarray['author-avatar'] = $postarray['owner-avatar'];
|
||||||
|
@ -1881,6 +1891,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl
|
||||||
$retweet['private'] = $postarray['private'];
|
$retweet['private'] = $postarray['private'];
|
||||||
$retweet['allow_cid'] = $postarray['allow_cid'];
|
$retweet['allow_cid'] = $postarray['allow_cid'];
|
||||||
$retweet['contact-id'] = $postarray['contact-id'];
|
$retweet['contact-id'] = $postarray['contact-id'];
|
||||||
|
$retweet['owner-id'] = $postarray['owner-id'];
|
||||||
$retweet['owner-name'] = $postarray['owner-name'];
|
$retweet['owner-name'] = $postarray['owner-name'];
|
||||||
$retweet['owner-link'] = $postarray['owner-link'];
|
$retweet['owner-link'] = $postarray['owner-link'];
|
||||||
$retweet['owner-avatar'] = $postarray['owner-avatar'];
|
$retweet['owner-avatar'] = $postarray['owner-avatar'];
|
||||||
|
|
Loading…
Reference in a new issue