From 186eaf1264320de3e5604d09b7ae7818ba5c4465 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 20 Mar 2016 10:30:06 +0100 Subject: [PATCH 1/3] Take the second largest picture as preview - not the smallest one --- mod/fbrowser.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 0a2a7dead..5836efbe5 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -74,10 +74,18 @@ function fbrowser_content($a){ $filename_e = $rr['filename']; } + // Take the second largest picture as preview + $p = q("SELECT `scale` FROM `photo` WHERE `resource-id` = '%s' AND `scale` > %d ORDER BY `resource-id`, `scale` LIMIT 1", + dbesc($rr['resource-id']), intval($rr['hiq'])); + if ($p) + $scale = $p[0]["scale"]; + else + $scale = $rr['loq']; + return array( $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], $filename_e, - $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext + $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext ); } $files = array_map("_map_files1", $r); From 8f00836ffb47758fa16101cafeb1a03d13d88de4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 20 Mar 2016 15:01:50 +0100 Subject: [PATCH 2/3] Add the guid to items that we create locally --- include/like.php | 1 + mod/dfrn_confirm.php | 3 ++- mod/mood.php | 2 +- mod/photos.php | 5 +++-- mod/poke.php | 1 + mod/profiles.php | 2 ++ mod/subthread.php | 5 +++-- mod/tagger.php | 5 +++-- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/like.php b/include/like.php index 646e0727b..d852cc3b3 100644 --- a/include/like.php +++ b/include/like.php @@ -196,6 +196,7 @@ EOT; $arr = array(); + $arr['guid'] = get_guid(32); $arr['uri'] = $uri; $arr['uid'] = $owner_uid; $arr['contact-id'] = $contact['id']; diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 68950ec28..aed9809ca 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -448,6 +448,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if(count($self)) { $arr = array(); + $arr['guid'] = get_guid(32); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $uid); $arr['uid'] = $uid; $arr['contact-id'] = $self[0]['id']; @@ -466,7 +467,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]'; $arr['verb'] = ACTIVITY_FRIEND; - $arr['object-type'] = ACTIVITY_OBJ_PERSON; + $arr['object-type'] = ACTIVITY_OBJ_PERSON; $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $contact['name'] . '' diff --git a/mod/mood.php b/mod/mood.php index eee11e20c..5e6ca0fcf 100644 --- a/mod/mood.php +++ b/mod/mood.php @@ -62,7 +62,7 @@ function mood_init(&$a) { $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]); $arr = array(); - + $arr['guid'] = get_guid(32); $arr['uid'] = $uid; $arr['uri'] = $uri; $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri); diff --git a/mod/photos.php b/mod/photos.php index 2257a9665..4761b627d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -488,7 +488,7 @@ function photos_post(&$a) { $uri = item_new_uri($a->get_hostname(),$page_owner_uid); $arr = array(); - + $arr['guid'] = get_guid(32); $arr['uid'] = $page_owner_uid; $arr['uri'] = $uri; $arr['parent-uri'] = $uri; @@ -677,7 +677,7 @@ function photos_post(&$a) { $uri = item_new_uri($a->get_hostname(),$page_owner_uid); $arr = array(); - + $arr['guid'] = get_guid(32); $arr['uid'] = $page_owner_uid; $arr['uri'] = $uri; $arr['parent-uri'] = $uri; @@ -904,6 +904,7 @@ function photos_post(&$a) { if($lat && $lon) $arr['coord'] = $lat . ' ' . $lon; + $arr['guid'] = get_guid(32); $arr['uid'] = $page_owner_uid; $arr['uri'] = $uri; $arr['parent-uri'] = $uri; diff --git a/mod/poke.php b/mod/poke.php index 45a577cda..4a643435b 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -91,6 +91,7 @@ function poke_init(&$a) { $arr = array(); + $arr['guid'] = get_guid(32); $arr['uid'] = $uid; $arr['uri'] = $uri; $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri); diff --git a/mod/profiles.php b/mod/profiles.php index 0b8261422..39382fbdd 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -526,6 +526,8 @@ function profile_activity($changed, $value) { return; $arr = array(); + + $arr['guid'] = get_guid(32); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); $arr['uid'] = local_user(); $arr['contact-id'] = $self[0]['id']; diff --git a/mod/subthread.php b/mod/subthread.php index 1486a33b4..33cf7489c 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -103,10 +103,11 @@ EOT; $bodyverb = t('%1$s is following %2$s\'s %3$s'); if(! isset($bodyverb)) - return; + return; $arr = array(); + $arr['guid'] = get_guid(32); $arr['uri'] = $uri; $arr['uid'] = $owner_uid; $arr['contact-id'] = $contact['id']; @@ -123,7 +124,7 @@ EOT; $arr['author-name'] = $contact['name']; $arr['author-link'] = $contact['url']; $arr['author-avatar'] = $contact['thumb']; - + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $plink = '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; diff --git a/mod/tagger.php b/mod/tagger.php index 2c469a58b..26166a3cc 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -95,12 +95,13 @@ EOT; $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); if(! isset($bodyverb)) - return; + return; $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $arr = array(); + $arr['guid'] = get_guid(32); $arr['uri'] = $uri; $arr['uid'] = $owner_uid; $arr['contact-id'] = $contact['id']; @@ -115,7 +116,7 @@ EOT; $arr['author-name'] = $contact['name']; $arr['author-link'] = $contact['url']; $arr['author-avatar'] = $contact['thumb']; - + $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $plink = '[url=' . $item['plink'] . ']' . $post_type . '[/url]'; From 77ed71e2e07ebbea9295308ba02fbc7e75ff927d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 20 Mar 2016 15:53:37 +0100 Subject: [PATCH 3/3] DFRN: Remote tagging works now --- include/dfrn.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/include/dfrn.php b/include/dfrn.php index 1c5ac2b01..d96805a56 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -85,7 +85,7 @@ class dfrn { $converse = true; if($a->argv[$x] == 'starred') $starred = true; - if($a->argv[$x] === 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1])) + if($a->argv[$x] == 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1])) $category = $a->argv[$x+1]; } } @@ -244,7 +244,7 @@ class dfrn { foreach($items as $item) { // prevent private email from leaking. - if($item['network'] === NETWORK_MAIL) + if($item['network'] == NETWORK_MAIL) continue; // public feeds get html, our own nodes use bbcode @@ -628,7 +628,7 @@ class dfrn { if($r->title) xml_add_element($doc, $entry, "title", $r->title); if($r->link) { - if(substr($r->link,0,1) === '<') { + if(substr($r->link,0,1) == '<') { if(strstr($r->link,'&') && (! strstr($r->link,'&'))) $r->link = str_replace('&','&', $r->link); @@ -759,7 +759,7 @@ class dfrn { // The "content" field is not read by the receiver. We could remove it when the type is "text" // We keep it at the moment, maybe there is some old version that doesn't read "dfrn:env" - xml_add_element($doc, $entry, "content", (($type === 'html') ? $htmlbody : $body), array("type" => $type)); + xml_add_element($doc, $entry, "content", (($type == 'html') ? $htmlbody : $body), array("type" => $type)); // We save this value in "plink". Maybe we should read it from there as well? xml_add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html", @@ -1773,6 +1773,9 @@ class dfrn { * @return bool Should the processing of the entries be continued? */ private function process_verbs($entrytype, $importer, &$item, &$is_like) { + + logger("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype, LOGGER_DEBUG); + if (($entrytype == DFRN_TOP_LEVEL)) { // The filling of the the "contact" variable is done for legcy reasons // The functions below are partly used by ostatus.php as well - where we have this variable @@ -1803,11 +1806,11 @@ class dfrn { return false; } } else { - if(($item["verb"] === ACTIVITY_LIKE) - || ($item["verb"] === ACTIVITY_DISLIKE) - || ($item["verb"] === ACTIVITY_ATTEND) - || ($item["verb"] === ACTIVITY_ATTENDNO) - || ($item["verb"] === ACTIVITY_ATTENDMAYBE)) { + if(($item["verb"] == ACTIVITY_LIKE) + || ($item["verb"] == ACTIVITY_DISLIKE) + || ($item["verb"] == ACTIVITY_ATTEND) + || ($item["verb"] == ACTIVITY_ATTENDNO) + || ($item["verb"] == ACTIVITY_ATTENDMAYBE)) { $is_like = true; $item["type"] = "activity"; $item["gravity"] = GRAVITY_LIKE; @@ -1833,7 +1836,7 @@ class dfrn { } else $is_like = false; - if(($item["verb"] === ACTIVITY_TAG) && ($item["object-type"] === ACTIVITY_OBJ_TAGTERM)) { + if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) { $xo = parse_xml_string($item["object"],false); $xt = parse_xml_string($item["target"],false); @@ -2261,15 +2264,17 @@ class dfrn { else return; - if($item["object-type"] === ACTIVITY_OBJ_EVENT) { + if($item["object-type"] == ACTIVITY_OBJ_EVENT) { logger("Deleting event ".$item["event-id"], LOGGER_DEBUG); event_delete($item["event-id"]); } - if(($item["verb"] === ACTIVITY_TAG) && ($item["object-type"] === ACTIVITY_OBJ_TAGTERM)) { + if(($item["verb"] == ACTIVITY_TAG) && ($item["object-type"] == ACTIVITY_OBJ_TAGTERM)) { + $xo = parse_xml_string($item["object"],false); $xt = parse_xml_string($item["target"],false); - if($xt->type === ACTIVITY_OBJ_NOTE) { + + if($xt->type == ACTIVITY_OBJ_NOTE) { $i = q("SELECT `id`, `contact-id`, `tag` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($xt->id), intval($importer["importer_uid"])