Merge pull request #204 from annando/master

fromgplus: Picture upload/usage of Object-Type and GUID
pull/207/head
tobiasd 2014-07-24 21:11:46 +02:00
commit 06fb3ef9b5
6 changed files with 141 additions and 64 deletions

View File

@ -12,6 +12,7 @@
- Use embedded pictures for the attachment information (large attachment) - Use embedded pictures for the attachment information (large attachment)
- Sound links must be handled - Sound links must be handled
- https://alpha.app.net/sr_rolando/post/32365203 - double pictures - https://alpha.app.net/sr_rolando/post/32365203 - double pictures
- https://alpha.app.net/opendev/post/34396399 - location data
*/ */
define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@ -715,7 +716,8 @@ function appnet_fetchstream($a, $uid) {
'to_email' => $user['email'], 'to_email' => $user['email'],
'uid' => $user['uid'], 'uid' => $user['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item, //'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],
@ -769,7 +771,8 @@ function appnet_fetchstream($a, $uid) {
'to_email' => $user['email'], 'to_email' => $user['email'],
'uid' => $user['uid'], 'uid' => $user['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item, //'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],
@ -866,8 +869,12 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
} }
// Don't create accounts of people who just comment something // Don't create accounts of people who just comment something
$createuser = false; $createuser = false;
} else
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
} else {
$postarray['thr-parent'] = $postarray['uri']; $postarray['thr-parent'] = $postarray['uri'];
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
}
$postarray['plink'] = $post["canonical_url"]; $postarray['plink'] = $post["canonical_url"];
@ -952,6 +959,10 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
$page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]"; $page_info = "\n[url=".$photo["url"]."][img]".$photo["large"]."[/img][/url]";
elseif ($photo["url"] != "") elseif ($photo["url"] != "")
$page_info = "\n[img]".$photo["url"]."[/img]"; $page_info = "\n[img]".$photo["url"]."[/img]";
if ($photo["url"] != "")
$postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
} else } else
$photo = array("url" => "", "large" => ""); $photo = array("url" => "", "large" => "");

View File

@ -229,6 +229,7 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$postarray['wall'] = 0; $postarray['wall'] = 0;
$postarray['verb'] = ACTIVITY_POST; $postarray['verb'] = ACTIVITY_POST;
$postarray['object-type'] = ACTIVITY_OBJ_NOTE; // default value - is maybe changed later when media is attached
$postarray['network'] = dbesc(NETWORK_FACEBOOK); $postarray['network'] = dbesc(NETWORK_FACEBOOK);
$postarray['uri'] = "fb::".$post->post_id; $postarray['uri'] = "fb::".$post->post_id;
@ -314,6 +315,24 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$postarray["body"] = $msgdata["body"]; $postarray["body"] = $msgdata["body"];
$postarray["tag"] = $msgdata["tags"]; $postarray["tag"] = $msgdata["tags"];
// Change the object type when an attachment is present
if (isset($post->attachment->fb_object_type))
logger('fb_object_type: '.$post->attachment->fb_object_type." ".print_r($post->attachment, true), LOGGER_DEBUG);
switch ($post->attachment->fb_object_type) {
case 'photo':
$postarray['object-type'] = ACTIVITY_OBJ_IMAGE; // photo is deprecated: http://activitystrea.ms/head/activity-schema.html#image
break;
case 'video':
$postarray['object-type'] = ACTIVITY_OBJ_VIDEO;
break;
case '':
//$postarray['object-type'] = ACTIVITY_OBJ_BOOKMARK;
break;
default:
logger('Unknown object type '.$post->attachment->fb_object_type, LOGGER_DEBUG);
break;
}
$content = ""; $content = "";
$type = ""; $type = "";
@ -328,43 +347,44 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr
$content = "[b]" . $post->attachment->name."[/b]"; $content = "[b]" . $post->attachment->name."[/b]";
$quote = ""; $quote = "";
if(isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo")) if (isset($post->attachment->description) and ($post->attachment->fb_object_type != "photo"))
$quote = $post->attachment->description; $quote = $post->attachment->description;
if(isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo")) if (isset($post->attachment->caption) and ($post->attachment->fb_object_type == "photo"))
$quote = $post->attachment->caption; $quote = $post->attachment->caption;
if ($quote.$post->attachment->href.$content.$postarray["body"] == "") if ($quote.$post->attachment->href.$content.$postarray["body"] == "")
return; return;
if (isset($post->attachment->media) // AND !strstr($post->attachment->href, "://www.youtube.com/") if (isset($post->attachment->media) AND (($type == "") OR ($type == "link"))) {
//AND !strstr($post->attachment->href, "://youtu.be/")
//AND !strstr($post->attachment->href, ".vimeo.com/"))
AND (($type == "") OR ($type == "link"))) {
foreach ($post->attachment->media AS $media) { foreach ($post->attachment->media AS $media) {
//$media->photo->owner = number_format($media->photo->owner, 0, '', '');
//if ($media->photo->owner != '') {
// $postarray['author-name'] = $contacts[$media->photo->owner]->name;
// $postarray['author-link'] = $contacts[$media->photo->owner]->url;
// $postarray['author-avatar'] = $contacts[$media->photo->owner]->pic_square;
//}
if (isset($media->type)) if (isset($media->type))
$type = $media->type; $type = $media->type;
if(isset($media->src) && isset($media->href) AND ($media->src != "") AND ($media->href != "")) if (isset($media->src))
$content .= "\n".'[url='.$media->href.'][img]'.fpost_cleanpicture($media->src).'[/img][/url]'; $preview = $media->src;
if (isset($media->photo))
if (isset($media->photo->images) AND (count($media->photo->images) > 1))
$preview = $media->photo->images[1]->src;
if (isset($media->href) AND ($preview != "") AND ($media->href != ""))
$content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]';
else { else {
if (isset($media->src) AND ($media->src != "")) if ($preview != "")
$content .= "\n".'[img]'.fpost_cleanpicture($media->src).'[/img]'; $content .= "\n".'[img]'.$preview.'[/img]';
// if just a link, it may be a wall photo - check // if just a link, it may be a wall photo - check
if(isset($post->link)) if (isset($post->link))
$content .= fbpost_get_photo($media->href); $content .= fbpost_get_photo($media->href);
} }
} }
} }
if ($type == "link")
$postarray["object-type"] = ACTIVITY_OBJ_BOOKMARK;
if ($content) if ($content)
$postarray["body"] .= "\n"; $postarray["body"] .= "\n";
@ -490,6 +510,7 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
$postarray['wall'] = 0; $postarray['wall'] = 0;
$postarray['verb'] = ACTIVITY_POST; $postarray['verb'] = ACTIVITY_POST;
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
$postarray['network'] = dbesc(NETWORK_FACEBOOK); $postarray['network'] = dbesc(NETWORK_FACEBOOK);
$postarray['uri'] = "fb::".$comment->id; $postarray['uri'] = "fb::".$comment->id;
@ -589,7 +610,8 @@ function fbsync_createcomment($a, $uid, $self_id, $self, $user, $contacts, $appl
'to_email' => $user[0]['email'], 'to_email' => $user[0]['email'],
'uid' => $user[0]['uid'], 'uid' => $user[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $item, //'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],
@ -641,8 +663,11 @@ function fbsync_createlike($a, $uid, $self_id, $self, $contacts, $like) {
$likedata = array(); $likedata = array();
$likedata['parent'] = $orig_post['id']; $likedata['parent'] = $orig_post['id'];
$likedata['verb'] = ACTIVITY_LIKE; $likedata['verb'] = ACTIVITY_LIKE;
$likedata['object-type'] = ACTIVITY_OBJ_NOTE;
$likedate['network'] = dbesc(NETWORK_FACEBOOK); $likedate['network'] = dbesc(NETWORK_FACEBOOK);
$likedata['gravity'] = 3; $likedata['gravity'] = 3;
$likedata['uid'] = $uid; $likedata['uid'] = $uid;
$likedata['wall'] = 0; $likedata['wall'] = 0;

View File

@ -195,14 +195,15 @@ function fromgplus_parse_query($var)
} }
function fromgplus_cleanupgoogleproxy($fullImage, $image) { function fromgplus_cleanupgoogleproxy($fullImage, $image) {
//$preview = "/w".$fullImage->width."-h".$fullImage->height."/";
//$preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
//$fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
$fullImage = $fullImage->url;
$preview = "/w".$fullImage->width."-h".$fullImage->height."/"; //$preview = "/w".$image->width."-h".$image->height."/";
$preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/"; //$preview2 = "/w".$image->width."-h".$image->height."-p/";
$fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url); //$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
$image = $image->url;
$preview = "/w".$image->width."-h".$image->height."/";
$preview2 = "/w".$image->width."-h".$image->height."-p/";
$image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
$cleaned = array(); $cleaned = array();
@ -227,7 +228,23 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
$cleaned["preview"] = ""; $cleaned["preview"] = "";
} }
if ($cleaned["full"] == $cleaned["preview"]) if ($cleaned["full"] != "")
$infoFull = get_photo_info($cleaned["full"]);
else
$infoFull = array("0" => 0, "1" => 0);
if ($cleaned["preview"] != "")
$infoPreview = get_photo_info($cleaned["preview"]);
else
$infoFull = array("0" => 0, "1" => 0);
if (($infoPreview[0] >= $infoFull[0]) AND ($infoPreview[1] >= $infoFull[1])) {
$temp = $cleaned["full"];
$cleaned["full"] = $cleaned["preview"];
$cleaned["preview"] = $temp;
}
if (($cleaned["full"] == $cleaned["preview"]) OR (($infoPreview[0] == $infoFull[0]) AND ($infoPreview[1] == $infoFull[1])))
$cleaned["preview"] = ""; $cleaned["preview"] = "";
if ($cleaned["full"] == "") if ($cleaned["full"] == "")
@ -236,7 +253,10 @@ function fromgplus_cleanupgoogleproxy($fullImage, $image) {
if ($cleaned["full"] == "") if ($cleaned["full"] == "")
if (@exif_imagetype($image) != 0) if (@exif_imagetype($image) != 0)
$cleaned["full"] = $fullImage; $cleaned["full"] = $image;
// Could be changed in the future to a link to the album
$cleaned["page"] = $cleaned["full"];
return($cleaned); return($cleaned);
} }
@ -253,7 +273,9 @@ function fromgplus_cleantext($text) {
return($text); return($text);
} }
function fromgplus_handleattachments($item, $displaytext) { function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
require_once("include/Photo.php");
$post = ""; $post = "";
$quote = ""; $quote = "";
$type = ""; $type = "";
@ -279,9 +301,18 @@ function fromgplus_handleattachments($item, $displaytext) {
break; break;
case "photo": case "photo":
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image); // Don't store shared pictures in your wall photos (to prevent a possible violating of licenses)
if ($shared)
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
else {
if ($attachment->fullImage->url != "")
$images = store_photo($a, $uid, "", $attachment->fullImage->url);
elseif ($attachment->image->url != "")
$images = store_photo($a, $uid, "", $attachment->image->url);
}
if ($images["preview"] != "") if ($images["preview"] != "")
$post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n"; $post .= "\n[url=".$images["page"]."][img]".$images["preview"]."[/img][/url]\n";
elseif ($images["full"] != "") elseif ($images["full"] != "")
$post .= "\n[img]".$images["full"]."[/img]\n"; $post .= "\n[img]".$images["full"]."[/img]\n";
@ -360,6 +391,12 @@ function fromgplus_fetch($a, $uid) {
if (strtotime($item->published) <= $initiallastdate) if (strtotime($item->published) <= $initiallastdate)
continue; continue;
// Don't publish items that are too young
if (strtotime($item->published) > (time() - 3*60)) {
logger('fromgplus_fetch: item too new '.$item->published);
continue;
}
if ($lastdate < strtotime($item->published)) if ($lastdate < strtotime($item->published))
$lastdate = strtotime($item->published); $lastdate = strtotime($item->published);
@ -381,7 +418,7 @@ function fromgplus_fetch($a, $uid) {
$post = fromgplus_html2bbcode($item->object->content); $post = fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments)) if (is_array($item->object->attachments))
$post .= fromgplus_handleattachments($item, $item->object->content); $post .= fromgplus_handleattachments($a, $uid, $item, $item->object->content, false);
// geocode, placeName // geocode, placeName
if (isset($item->address)) if (isset($item->address))
@ -406,7 +443,7 @@ function fromgplus_fetch($a, $uid) {
$post .= fromgplus_html2bbcode($item->object->content); $post .= fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments)) if (is_array($item->object->attachments))
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content)); $post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
$post .= "[/share]"; $post .= "[/share]";
} else { } else {
@ -415,7 +452,7 @@ function fromgplus_fetch($a, $uid) {
$post .= fromgplus_html2bbcode($item->object->content); $post .= fromgplus_html2bbcode($item->object->content);
if (is_array($item->object->attachments)) if (is_array($item->object->attachments))
$post .= "\n".trim(fromgplus_handleattachments($item, $item->object->content)); $post .= "\n".trim(fromgplus_handleattachments($a, $uid, $item, $item->object->content, true));
} }
if (isset($item->address)) if (isset($item->address))
@ -431,22 +468,3 @@ function fromgplus_fetch($a, $uid) {
if ($lastdate != 0) if ($lastdate != 0)
set_pconfig($uid,'fromgplus','lastdate', $lastdate); set_pconfig($uid,'fromgplus','lastdate', $lastdate);
} }
/*
// Test
require_once("boot.php");
if(@is_null($a)) {
$a = new App;
}
if(@is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data);
unset($db_host, $db_user, $db_pass, $db_data);
};
$test = array();
fromgplus_cron($a, $test);
*/

View File

@ -472,6 +472,9 @@ function pumpio_send(&$a,&$b) {
$inReplyTo = array("id" => $orig_post["uri"], $inReplyTo = array("id" => $orig_post["uri"],
"objectType" => "note"); "objectType" => "note");
if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
$inReplyTo["objectType"] = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
$params["object"] = array( $params["object"] = array(
'objectType' => "comment", 'objectType' => "comment",
'content' => $title.$content, 'content' => $title.$content,
@ -546,7 +549,9 @@ function pumpio_action(&$a, $uid, $uri, $action, $content) {
else else
$uri = $orig_post["uri"]; $uri = $orig_post["uri"];
if (strstr($uri, "/api/comment/")) if (($orig_post["object-type"] != "") AND (strstr($orig_post["object-type"], NAMESPACE_ACTIVITY_SCHEMA)))
$objectType = str_replace(NAMESPACE_ACTIVITY_SCHEMA, '', $orig_post["object-type"]);
elseif (strstr($uri, "/api/comment/"))
$objectType = "comment"; $objectType = "comment";
elseif (strstr($uri, "/api/note/")) elseif (strstr($uri, "/api/note/"))
$objectType = "note"; $objectType = "note";
@ -865,7 +870,6 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id) {
$likedata['parent-uri'] = $orig_post["uri"]; $likedata['parent-uri'] = $orig_post["uri"];
$likedata['contact-id'] = $contactid; $likedata['contact-id'] = $contactid;
$likedata['app'] = $post->generator->displayName; $likedata['app'] = $post->generator->displayName;
$likedata['verb'] = ACTIVITY_LIKE;
$likedata['author-name'] = $post->actor->displayName; $likedata['author-name'] = $post->actor->displayName;
$likedata['author-link'] = $post->actor->url; $likedata['author-link'] = $post->actor->url;
$likedata['author-avatar'] = $post->actor->image->url; $likedata['author-avatar'] = $post->actor->image->url;
@ -1081,6 +1085,7 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
$postarray['uid'] = $uid; $postarray['uid'] = $uid;
$postarray['wall'] = 0; $postarray['wall'] = 0;
$postarray['uri'] = $post->object->id; $postarray['uri'] = $post->object->id;
$postarray['object-type'] = NAMESPACE_ACTIVITY_SCHEMA.strtolower($post->object->objectType);
if ($post->object->objectType != "comment") { if ($post->object->objectType != "comment") {
$contact_id = pumpio_get_contact($uid, $post->actor); $contact_id = pumpio_get_contact($uid, $post->actor);
@ -1238,7 +1243,8 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
'to_email' => $user[0]['email'], 'to_email' => $user[0]['email'],
'uid' => $user[0]['uid'], 'uid' => $user[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item, //'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($top_item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],

View File

@ -1078,6 +1078,7 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
if (count($r)) { if (count($r)) {
$postarray['thr-parent'] = $r[0]["uri"]; $postarray['thr-parent'] = $r[0]["uri"];
$postarray['parent-uri'] = $r[0]["parent-uri"]; $postarray['parent-uri'] = $r[0]["parent-uri"];
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
} else { } else {
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent), dbesc($parent),
@ -1086,9 +1087,11 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
if (count($r)) { if (count($r)) {
$postarray['thr-parent'] = $r[0]['uri']; $postarray['thr-parent'] = $r[0]['uri'];
$postarray['parent-uri'] = $r[0]['parent-uri']; $postarray['parent-uri'] = $r[0]['parent-uri'];
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
} else { } else {
$postarray['thr-parent'] = $postarray['uri']; $postarray['thr-parent'] = $postarray['uri'];
$postarray['parent-uri'] = $postarray['uri']; $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
} }
} }
@ -1110,8 +1113,10 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
} }
// Don't create accounts of people who just comment something // Don't create accounts of people who just comment something
$create_user = false; $create_user = false;
} else } else {
$postarray['parent-uri'] = $postarray['uri']; $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
}
if ($contactid == 0) { if ($contactid == 0) {
$contactid = statusnet_fetch_contact($uid, $post->user, $create_user); $contactid = statusnet_fetch_contact($uid, $post->user, $create_user);
@ -1127,6 +1132,7 @@ function statusnet_createpost($a, $uid, $post, $self, $create_user, $only_existi
$postarray['contact-id'] = $contactid; $postarray['contact-id'] = $contactid;
$postarray['verb'] = ACTIVITY_POST; $postarray['verb'] = ACTIVITY_POST;
$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'];
@ -1231,7 +1237,8 @@ function statusnet_checknotification($a, $uid, $own_url, $top_item, $postarray)
'to_email' => $user[0]['email'], 'to_email' => $user[0]['email'],
'uid' => $user[0]['uid'], 'uid' => $user[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item, //'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($top_item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],
@ -1412,7 +1419,8 @@ function statusnet_fetchhometimeline($a, $uid) {
'to_email' => $u[0]['email'], 'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'], 'uid' => $u[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item, //'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],

View File

@ -1243,6 +1243,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
if (count($r)) { if (count($r)) {
$postarray['thr-parent'] = $r[0]["uri"]; $postarray['thr-parent'] = $r[0]["uri"];
$postarray['parent-uri'] = $r[0]["parent-uri"]; $postarray['parent-uri'] = $r[0]["parent-uri"];
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
} else { } else {
$r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent), dbesc($parent),
@ -1251,9 +1252,11 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
if (count($r)) { if (count($r)) {
$postarray['thr-parent'] = $r[0]['uri']; $postarray['thr-parent'] = $r[0]['uri'];
$postarray['parent-uri'] = $r[0]['parent-uri']; $postarray['parent-uri'] = $r[0]['parent-uri'];
$postarray['object-type'] = ACTIVITY_OBJ_COMMENT;
} else { } else {
$postarray['thr-parent'] = $postarray['uri']; $postarray['thr-parent'] = $postarray['uri'];
$postarray['parent-uri'] = $postarray['uri']; $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
} }
} }
@ -1275,8 +1278,10 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
} }
// Don't create accounts of people who just comment something // Don't create accounts of people who just comment something
$create_user = false; $create_user = false;
} else } else {
$postarray['parent-uri'] = $postarray['uri']; $postarray['parent-uri'] = $postarray['uri'];
$postarray['object-type'] = ACTIVITY_OBJ_NOTE;
}
if ($contactid == 0) { if ($contactid == 0) {
$contactid = twitter_fetch_contact($uid, $post->user, $create_user); $contactid = twitter_fetch_contact($uid, $post->user, $create_user);
@ -1317,6 +1322,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
//$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']); //$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
//$has_picture = true; //$has_picture = true;
$postarray['body'] = str_replace($media->url, "", $postarray['body']); $postarray['body'] = str_replace($media->url, "", $postarray['body']);
$postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
$picture = $media->media_url_https; $picture = $media->media_url_https;
break; break;
default: default:
@ -1358,6 +1364,7 @@ function twitter_createpost($a, $uid, $post, $self, $create_user, $only_existing
//$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']); //$postarray['body'] = str_replace($media->url, "\n\n[img]".$media->media_url_https."[/img]\n", $postarray['body']);
//$has_picture = true; //$has_picture = true;
$postarray['body'] = str_replace($media->url, "", $postarray['body']); $postarray['body'] = str_replace($media->url, "", $postarray['body']);
$postarray['object-type'] = ACTIVITY_OBJ_IMAGE;
$picture = $media->media_url_https; $picture = $media->media_url_https;
break; break;
default: default:
@ -1445,7 +1452,8 @@ function twitter_checknotification($a, $uid, $own_id, $top_item, $postarray) {
'to_email' => $user[0]['email'], 'to_email' => $user[0]['email'],
'uid' => $user[0]['uid'], 'uid' => $user[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item, //'link' => $a->get_baseurl() . '/display/' . $user[0]['nickname'] . '/' . $top_item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($top_item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],
@ -1606,7 +1614,8 @@ function twitter_fetchhometimeline($a, $uid) {
'to_email' => $u[0]['email'], 'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'], 'uid' => $u[0]['uid'],
'item' => $postarray, 'item' => $postarray,
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item, //'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
'link' => $a->get_baseurl().'/display/'.get_item_guid($item),
'source_name' => $postarray['author-name'], 'source_name' => $postarray['author-name'],
'source_link' => $postarray['author-link'], 'source_link' => $postarray['author-link'],
'source_photo' => $postarray['author-avatar'], 'source_photo' => $postarray['author-avatar'],