}
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
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",
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),
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',
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',
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",
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'];
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)
);
$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) {
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');
'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'],
'verb' => ACTIVITY_TAG,
- 'otype' => 'item'
+ 'otype' => 'item',
+ 'parent' => $parent_id
));
}
}