}
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 (($footerlink != "") AND (trim($footer) != "")) {
$removedlink = trim(str_replace($footerlink, "", $body));
- if (strstr($body, $removedlink))
+ if (($removedlink == "") OR strstr($body, $removedlink))
$body = $removedlink;
$body .= $footer;
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",
dbesc($parent),
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'];
$postarray['parent-uri'] = $postarray['uri'];
+ $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
}
}
}
// Don't create accounts of people who just comment something
$create_user = false;
- } else
+ } else {
$postarray['parent-uri'] = $postarray['uri'];
+ $postarray['object-type'] = ACTIVITY_OBJ_NOTE;
+ }
if ($contactid == 0) {
$contactid = twitter_fetch_contact($uid, $post->user, $create_user);
//$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
//$has_picture = true;
$postarray['body'] = str_replace($media->url, "", $postarray['body']);
+ $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
$picture = $media->media_url_https;
break;
default:
//$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
//$has_picture = true;
$postarray['body'] = str_replace($media->url, "", $postarray['body']);
+ $postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
$picture = $media->media_url_https;
break;
default:
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)
);
'to_email' => $user[0]['email'],
'uid' => $user[0]['uid'],
'item' => $postarray,
- 'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($top_item)),
'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'],
$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');
'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'],
'item' => $postarray,
- 'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($item)),
'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'],
'verb' => ACTIVITY_TAG,
- 'otype' => 'item'
+ 'otype' => 'item',
+ 'parent' => $parent_id
));
}
}