X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=380121c2e2a40bc0d820e2417021b077a3bfda33;hb=9e9916a8d5518860fda327de2d2e87d878efc0d2;hp=6731e324f04e88062ab455cfee449efc7a2a6e88;hpb=3ec6970d09270ebe57f75fc7295d38b8df1f5675;p=friendica-addons.git diff --git a/twitter/twitter.php b/twitter/twitter.php index 6731e324..380121c2 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -438,6 +438,9 @@ function twitter_post_hook(&$a,&$b) { return; // if post comes from twitter don't send it back + if($b['extid'] == NETWORK_TWITTER) + return; + if($b['app'] == "Twitter") return; @@ -743,7 +746,9 @@ function twitter_fetchtimeline($a, $uid) { $_REQUEST["type"] = "wall"; $_REQUEST["api_source"] = true; $_REQUEST["profile_uid"] = $uid; - $_REQUEST["source"] = "Twitter"; + //$_REQUEST["source"] = "Twitter"; + $_REQUEST["source"] = $post->source; + $_REQUEST["extid"] = NETWORK_TWITTER; //$_REQUEST["date"] = $post->created_at; @@ -890,6 +895,16 @@ function twitter_queue_hook(&$a,&$b) { } function twitter_fetch_contact($uid, $contact, $create_user) { + require_once("include/Photo.php"); + + if ($contact->id_str == "") + return(-1); + + $avatar = str_replace("_normal.", ".", $contact->profile_image_url_https); + + $info = get_photo_info($avatar); + if (!$info) + $avatar = $contact->profile_image_url_https; // Check if the unique contact is existing // To-Do: only update once a while @@ -901,12 +916,12 @@ function twitter_fetch_contact($uid, $contact, $create_user) { dbesc(normalise_link("https://twitter.com/".$contact->screen_name)), dbesc($contact->name), dbesc($contact->screen_name), - dbesc($contact->profile_image_url_https)); + dbesc($avatar)); else q("UPDATE unique_contacts SET name = '%s', nick = '%s', avatar = '%s' WHERE url = '%s'", dbesc($contact->name), dbesc($contact->screen_name), - dbesc($contact->profile_image_url_https), + dbesc($avatar), dbesc(normalise_link("https://twitter.com/".$contact->screen_name))); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", @@ -936,7 +951,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) { dbesc("twitter::".$contact->id_str), dbesc($contact->name), dbesc($contact->screen_name), - dbesc($contact->profile_image_url_https), + dbesc($avatar), dbesc(NETWORK_TWITTER), intval(CONTACT_IS_FRIEND), intval(1), @@ -964,7 +979,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) { require_once("Photo.php"); - $photos = import_profile_photo($contact->profile_image_url_https,$uid,$contact_id); + $photos = import_profile_photo($avatar,$uid,$contact_id); q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', @@ -996,7 +1011,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) { require_once("Photo.php"); - $photos = import_profile_photo($contact->profile_image_url_https, $uid, $r[0]['id']); + $photos = import_profile_photo($avatar, $uid, $r[0]['id']); q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', @@ -1243,6 +1258,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing if (count($r)) { $postarray['thr-parent'] = $r[0]["uri"]; $postarray['parent-uri'] = $r[0]["parent-uri"]; + $postarray['parent'] = $r[0]["parent"]; $postarray['object-type'] = ACTIVITY_OBJ_COMMENT; } else { $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", @@ -1252,6 +1268,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing if (count($r)) { $postarray['thr-parent'] = $r[0]['uri']; $postarray['parent-uri'] = $r[0]['parent-uri']; + $postarray['parent'] = $r[0]['parent']; $postarray['object-type'] = ACTIVITY_OBJ_COMMENT; } else { $postarray['thr-parent'] = $postarray['uri']; @@ -1404,6 +1421,8 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) { + // this whole function doesn't seem to work. Needs complete check + $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid) ); @@ -1592,6 +1611,9 @@ function twitter_fetchhometimeline($a, $uid) { $item = item_store($postarray); + if (!isset($postarray["parent"]) OR ($postarray["parent"] == 0)) + $postarray["parent"] = $item; + logger('twitter_fetchhometimeline: User '.$self["nick"].' posted mention timeline item '.$item); if ($item == 0) { @@ -1599,9 +1621,12 @@ function twitter_fetchhometimeline($a, $uid) { dbesc($postarray['uri']), intval($uid) ); - if (count($r)) + if (count($r)) { $item = $r[0]['id']; - } + $parent_id = $r[0]['parent']; + } + } else + $parent_id = $postarray['parent']; if ($item != 0) { require_once('include/enotify.php'); @@ -1618,7 +1643,8 @@ function twitter_fetchhometimeline($a, $uid) { 'source_link' => $postarray['author-link'], 'source_photo' => $postarray['author-avatar'], 'verb' => ACTIVITY_TAG, - 'otype' => 'item' + 'otype' => 'item', + 'parent' => $parent_id )); } }