X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fostatus.php;h=5c5016d0fce9ab8044c1d22c6dd560fdf108c3ff;hb=73f4c3c8da007cec58494cb1b09b31fe0b77b794;hp=00022f8c6cdd3ddfccf500d73e936008ab51814d;hpb=909bca90e872be898c36aadac175b93badce5460;p=friendica.git diff --git a/include/ostatus.php b/include/ostatus.php index 00022f8c6c..5c5016d0fc 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -164,8 +164,6 @@ function ostatus_fetchauthor($xpath, $context, $importer, &$contact, $onlyfetch) update_contact_avatar($author["author-avatar"], $importer["uid"], $contact["id"]); } - - /// @todo Add the "addr" field $contact["generation"] = 2; $contact["photo"] = $author["author-avatar"]; update_gcontact($contact); @@ -626,6 +624,59 @@ function check_conversations($mentions = false, $override = false) { set_config('system','ostatus_last_poll', time()); } +/** + * @brief Updates the gcontact table with actor data from the conversation + * + * @param object $actor The actor object that contains the contact data + */ +function ostatus_conv_fetch_actor($actor) { + + // We set the generation to "3" since the data here is not as reliable as the data we get on other occasions + $contact = array("network" => NETWORK_OSTATUS, "generation" => 3); + + if (isset($actor->url)) + $contact["url"] = $actor->url; + + if (isset($actor->displayName)) + $contact["name"] = $actor->displayName; + + if (isset($actor->portablecontacts_net->displayName)) + $contact["name"] = $actor->portablecontacts_net->displayName; + + if (isset($actor->portablecontacts_net->preferredUsername)) + $contact["nick"] = $actor->portablecontacts_net->preferredUsername; + + if (isset($actor->id)) + $contact["alias"] = $actor->id; + + if (isset($actor->summary)) + $contact["about"] = $actor->summary; + + if (isset($actor->portablecontacts_net->note)) + $contact["about"] = $actor->portablecontacts_net->note; + + if (isset($actor->portablecontacts_net->addresses->formatted)) + $contact["location"] = $actor->portablecontacts_net->addresses->formatted; + + + if (isset($actor->image->url)) + $contact["photo"] = $actor->image->url; + + if (isset($actor->image->width)) + $avatarwidth = $actor->image->width; + + if (is_array($actor->status_net->avatarLinks)) + foreach ($actor->status_net->avatarLinks AS $avatar) { + if ($avatarsize < $avatar->width) { + $contact["photo"] = $avatar->url; + $avatarsize = $avatar->width; + } + } + + update_gcontact($contact); +} + + function ostatus_completion($conversation_url, $uid, $item = array()) { $a = get_app(); @@ -729,6 +780,9 @@ function ostatus_completion($conversation_url, $uid, $item = array()) { foreach ($items as $single_conv) { + // Update the gcontact table + ostatus_conv_fetch_actor($single_conv->actor); + // Test - remove before flight //$tempfile = tempnam(get_temppath(), "conversation"); //file_put_contents($tempfile, json_encode($single_conv));