fix a couple of FB issues, wrong comment author, perhaps fix some missing entries

This commit is contained in:
Friendika 2011-05-14 00:47:00 -07:00
parent 7942192e20
commit 2b720b5b7c

View File

@ -700,26 +700,27 @@ function fb_consume_stream($uid,$j,$wall = false) {
if(is_array($likers)) { if(is_array($likers)) {
foreach($likers as $likes) { foreach($likers as $likes) {
$r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s' AND `author-link` = '%s' if(! $orig_post)
LIMIT 1", continue;
dbesc('fb::' . $entry->id),
$r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s' AND `author-link` = '%s' LIMIT 1",
dbesc($orig_post['uri']),
intval($uid), intval($uid),
dbesc(ACTIVITY_LIKE), dbesc(ACTIVITY_LIKE),
dbesc('http://facebook.com/profile.php?id=' . $likes->id) dbesc('http://facebook.com/profile.php?id=' . $likes->id)
); );
if(count($r)) if(count($r))
continue; continue;
$likedata = array(); $likedata = array();
$likedata['parent'] = $top_item; $likedata['parent'] = $top_item;
$likedata['verb'] = ACTIVITY_LIKE; $likedata['verb'] = ACTIVITY_LIKE;
$likedata['gravity'] = 3; $likedata['gravity'] = 3;
$likedata['uid'] = $uid; $likedata['uid'] = $uid;
$likedata['wall'] = (($wall) ? 1 : 0); $likedata['wall'] = (($wall) ? 1 : 0);
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid); $likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
$likedata['parent-uri'] = 'fb::' . $entry->id; $likedata['parent-uri'] = $orig_post['uri'];
if($likes->id == $self_id) if($likes->id == $self_id)
$likedata['contact-id'] = $self[0]['id']; $likedata['contact-id'] = $self[0]['id'];
else { else {
@ -754,6 +755,9 @@ function fb_consume_stream($uid,$j,$wall = false) {
if(is_array($comments)) { if(is_array($comments)) {
foreach($comments as $cmnt) { foreach($comments as $cmnt) {
if(! $orig_post)
continue;
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND ( `uri` = '%s' OR `extid` = '%s' ) LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uid` = %d AND ( `uri` = '%s' OR `extid` = '%s' ) LIMIT 1",
intval($uid), intval($uid),
dbesc('fb::' . $cmnt->id), dbesc('fb::' . $cmnt->id),
@ -769,12 +773,10 @@ function fb_consume_stream($uid,$j,$wall = false) {
$cmntdata['uid'] = $uid; $cmntdata['uid'] = $uid;
$cmntdata['wall'] = (($wall) ? 1 : 0); $cmntdata['wall'] = (($wall) ? 1 : 0);
$cmntdata['uri'] = 'fb::' . $cmnt->id; $cmntdata['uri'] = 'fb::' . $cmnt->id;
$cmntdata['parent-uri'] = 'fb::' . $entry->id; $cmntdata['parent-uri'] = $orig_post['uri'];
if($cmnt->from->id == $self_id) { if($cmnt->from->id == $self_id) {
$cmntdata['contact-id'] = $self[0]['id']; $cmntdata['contact-id'] = $self[0]['id'];
} }
elseif(is_array($orig_post) && (x($orig_post,'contact-id')))
$cmntdata['contact-id'] = $orig_post['contact-id'];
else { else {
$r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
dbesc($cmnt->from->id), dbesc($cmnt->from->id),
@ -783,8 +785,10 @@ function fb_consume_stream($uid,$j,$wall = false) {
if(count($r)) if(count($r))
$cmntdata['contact-id'] = $r[0]['id']; $cmntdata['contact-id'] = $r[0]['id'];
} }
if(! x($cmntdata,'contact-id')) if(! x($cmntdata,'contact-id')) {
logger('fb_consume: comment: no contact-id available');
return; return;
}
$cmntdata['created'] = datetime_convert('UTC','UTC',$cmnt->created_time); $cmntdata['created'] = datetime_convert('UTC','UTC',$cmnt->created_time);
$cmntdata['edited'] = datetime_convert('UTC','UTC',$cmnt->created_time); $cmntdata['edited'] = datetime_convert('UTC','UTC',$cmnt->created_time);
$cmntdata['verb'] = ACTIVITY_POST; $cmntdata['verb'] = ACTIVITY_POST;