From a720c4f5013d345fc21179dc39b346df13f3798d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 07:22:01 +0000 Subject: [PATCH 01/21] Removed unneeded fields from the API --- include/api.php | 217 ++++++++++++++---------------------------------- 1 file changed, 63 insertions(+), 154 deletions(-) diff --git a/include/api.php b/include/api.php index 8ffe27e74..54176da79 100644 --- a/include/api.php +++ b/include/api.php @@ -670,6 +670,7 @@ function api_get_user(App $a, $contact_id = null) 'statusnet_profile_url' => $r[0]["url"], 'uid' => 0, 'cid' => Contact::getIdForURL($r[0]["url"], api_user(), true), + 'pid' => Contact::getIdForURL($r[0]["url"], 0, true), 'self' => 0, 'network' => $r[0]["network"], ]; @@ -809,6 +810,7 @@ function api_get_user(App $a, $contact_id = null) 'statusnet_profile_url' => $uinfo[0]['url'], 'uid' => intval($uinfo[0]['uid']), 'cid' => intval($uinfo[0]['cid']), + 'pid' => Contact::getIdForURL($uinfo[0]["url"], 0, true), 'self' => $uinfo[0]['self'], 'network' => $uinfo[0]['network'], ]; @@ -856,16 +858,12 @@ function api_get_user(App $a, $contact_id = null) */ function api_item_get_user(App $a, $item) { - $status_user = api_get_user($a, $item["author-link"]); + $status_user = api_get_user($a, $item["author-id"]); - $status_user["protected"] = (($item["allow_cid"] != "") || - ($item["allow_gid"] != "") || - ($item["deny_cid"] != "") || - ($item["deny_gid"] != "") || - $item["private"]); + $status_user["protected"] = $item["private"]; if ($item['thr-parent'] == $item['uri']) { - $owner_user = api_get_user($a, $item["owner-link"]); + $owner_user = api_get_user($a, $item["owner-id"]); } else { $owner_user = $status_user; } @@ -1356,31 +1354,17 @@ function api_status_show($type) logger('api_status_show: user_info: '.print_r($user_info, true), LOGGER_DEBUG); if ($type == "raw") { - $privacy_sql = "AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''"; + $privacy_sql = "AND NOT `private`"; } else { $privacy_sql = ""; } // get last public wall message - $lastwall = q( - "SELECT `item`.* - FROM `item` - WHERE `item`.`contact-id` = %d AND `item`.`uid` = %d - AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) - AND `item`.`type` != 'activity' $privacy_sql - ORDER BY `item`.`id` DESC - LIMIT 1", - intval($user_info['cid']), - intval(api_user()), - dbesc($user_info['url']), - dbesc(normalise_link($user_info['url'])), - dbesc($user_info['url']), - dbesc(normalise_link($user_info['url'])) - ); + $condition = ["`owner-id` = ? AND `uid` = ? AND `type` != 'activity' ".$privacy_sql, + $user_info['pid'], api_user()]; + $lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]); if (DBM::is_result($lastwall)) { - $lastwall = $lastwall[0]; - $in_reply_to = api_in_reply_to($lastwall); $converted = api_convert_item($lastwall); @@ -1428,10 +1412,10 @@ function api_status_show($type) $status_info["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") && ($status_info["source"] == 'web')) { - $status_info["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']); - } elseif (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $status_info["source"])) { - $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['item_network'], $user_info['url']).')'); + if ($status_info["source"] == 'web') { + $status_info["source"] = ContactSelector::networkToName($lastwall['network'], $user_info['url']); + } elseif (ContactSelector::networkToName($lastwall['network'], $user_info['url']) != $status_info["source"]) { + $status_info["source"] = trim($status_info["source"].' ('.ContactSelector::networkToName($lastwall['network'], $user_info['url']).')'); } // "uid" and "self" are only needed for some internal stuff, so remove it from here @@ -1460,28 +1444,12 @@ function api_users_show($type) $a = get_app(); $user_info = api_get_user($a); - $lastwall = q( - "SELECT `item`.* - FROM `item` - INNER JOIN `contact` ON `contact`.`id`=`item`.`contact-id` AND `contact`.`uid` = `item`.`uid` - WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`contact-id` = %d - AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s'))) - AND `type`!='activity' - AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`='' - ORDER BY `id` DESC - LIMIT 1", - intval(api_user()), - dbesc(ACTIVITY_POST), - intval($user_info['cid']), - dbesc($user_info['url']), - dbesc(normalise_link($user_info['url'])), - dbesc($user_info['url']), - dbesc(normalise_link($user_info['url'])) - ); + + $condition = ["`owner-id` = ? AND `uid` = ? AND `verb` = ? AND `type` != 'activity' AND NOT `private`", + $user_info['pid'], api_user(), ACTIVITY_POST]; + $lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]); if (DBM::is_result($lastwall)) { - $lastwall = $lastwall[0]; - $in_reply_to = api_in_reply_to($lastwall); $converted = api_convert_item($lastwall); @@ -1519,12 +1487,12 @@ function api_users_show($type) $user_info["status"]["entities"] = $converted["entities"]; } - if (($lastwall['item_network'] != "") && ($user_info["status"]["source"] == 'web')) { - $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['item_network'], $user_info['url']); + if ($user_info["status"]["source"] == 'web') { + $user_info["status"]["source"] = ContactSelector::networkToName($lastwall['network'], $user_info['url']); } - if (($lastwall['item_network'] != "") && (ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) != $user_info["status"]["source"])) { - $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['item_network'], $user_info['url']) . ')'); + if (ContactSelector::networkToName($lastwall['network'], $user_info['url']) != $user_info["status"]["source"]) { + $user_info["status"]["source"] = trim($user_info["status"]["source"] . ' (' . ContactSelector::networkToName($lastwall['network'], $user_info['url']) . ')'); } } @@ -1735,19 +1703,14 @@ function api_statuses_home_timeline($type) $sql_extra .= ' AND `item`.`parent` = ' . intval($conversation_id); } - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` $sql_extra - AND `item`.`id`>%d - ORDER BY `item`.`id` DESC LIMIT %d ,%d ", + AND `item`.`id` > %d + ORDER BY `item`.`id` DESC LIMIT %d ,%d", intval(api_user()), dbesc(ACTIVITY_POST), intval($since_id), @@ -2016,12 +1979,8 @@ function api_statuses_show($type) $id = $item['id']; $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + "SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` AND `item`.`uid` IN (0, %d) AND `item`.`verb` = '%s' @@ -2107,13 +2066,8 @@ function api_conversation_show($type) $sql_extra = ' AND `item`.`id` <= ' . intval($max_id); } - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -2175,17 +2129,11 @@ function api_statuses_repeat($type) logger('API: api_statuses_repeat: '.$id); - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`nick` as `reply_author`, - `contact`.`name`, `contact`.`photo` as `reply_photo`, `contact`.`url` as `reply_url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` - AND NOT `item`.`private` AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' - AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' + AND NOT `item`.`private` AND `item`.`id`=%d", intval($id) ); @@ -2299,36 +2247,25 @@ function api_statuses_mentions($type) $start = ($page - 1) * $count; - // Ugly code - should be changed - $myurl = System::baseUrl() . '/profile/'. $a->user['nickname']; - $myurl = substr($myurl, strpos($myurl, '://') + 3); - $myurl = str_replace('www.', '', $myurl); - $sql_extra = ''; if ($max_id > 0) { - $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id); + $sql_extra = ' AND `item`.`id` <= ' . intval($max_id); } - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` FORCE INDEX (`uid_id`) - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `item`.* FROM `item` FORCE INDEX (`uid_id`) + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) - WHERE `item`.`uid` = %d AND `verb` = '%s' - AND NOT (`item`.`author-link` IN ('https://%s', 'http://%s')) + WHERE `item`.`uid` = %d AND `item`.`verb` = '%s' + AND `item`.`author-id` != %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` - AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = %d AND `mention` AND !`ignored`) + AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = %d AND `mention` AND NOT `ignored`) $sql_extra - AND `item`.`id`>%d - ORDER BY `item`.`id` DESC LIMIT %d ,%d ", + AND `item`.`id` > %d + ORDER BY `item`.`id` DESC LIMIT %d ,%d", intval(api_user()), dbesc(ACTIVITY_POST), - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($myurl)), + intval($user_info['pid']), intval(api_user()), intval($since_id), intval($start), @@ -2408,20 +2345,15 @@ function api_statuses_user_timeline($type) $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id); } - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` FORCE INDEX (`uid_contactid_id`) - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `item`.* FROM `item` FORCE INDEX (`uid_contactid_id`) + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d AND `verb` = '%s' AND `item`.`contact-id` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` $sql_extra AND `item`.`id` > %d - ORDER BY `item`.`id` DESC LIMIT %d ,%d ", + ORDER BY `item`.`id` DESC LIMIT %d ,%d", intval(api_user()), dbesc(ACTIVITY_POST), intval($user_info['cid']), @@ -2566,20 +2498,15 @@ function api_favorites($type) $sql_extra .= ' AND `item`.`id` <= ' . intval($max_id); } - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item`, `contact` + $r = q("SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`uid` = %d - AND `item`.`visible` = 1 AND `item`.`moderated` = 0 AND `item`.`deleted` = 0 - AND `item`.`starred` = 1 - AND `contact`.`id` = `item`.`contact-id` - AND (NOT `contact`.`blocked` OR `contact`.`pending`) + AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` + AND `item`.`starred` $sql_extra AND `item`.`id`>%d - ORDER BY `item`.`id` DESC LIMIT %d ,%d ", + ORDER BY `item`.`id` DESC LIMIT %d ,%d", intval(api_user()), intval($since_id), intval($start), @@ -3001,8 +2928,8 @@ function api_format_items_activities(&$item, $type = "json") ]; $items = q( - 'SELECT * FROM item - WHERE uid=%d AND `thr-parent`="%s" AND visible AND NOT deleted', + 'SELECT * FROM `item` + WHERE `uid` = %d AND `thr-parent` = "%s" AND `visible` AND NOT `deleted`', intval($item['uid']), dbesc($item['uri']) ); @@ -3012,7 +2939,7 @@ function api_format_items_activities(&$item, $type = "json") //builtin_activity_puller($i, $activities); // get user data and add it to the array of the activity - $user = api_get_user($a, $i['author-link']); + $user = api_get_user($a, $i['author-id']); switch ($i['verb']) { case ACTIVITY_LIKE: $activities['like'][] = $user; @@ -3168,26 +3095,18 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json") $status["entities"] = $converted["entities"]; } - if (($item['item_network'] != "") && ($status["source"] == 'web')) { - $status["source"] = ContactSelector::networkToName($item['item_network'], $user_info['url']); - } elseif (($item['item_network'] != "") && (ContactSelector::networkToName($item['item_network'], $user_info['url']) != $status["source"])) { - $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['item_network'], $user_info['url']).')'); + if ($status["source"] == 'web') { + $status["source"] = ContactSelector::networkToName($item['network'], $user_info['url']); + } elseif (ContactSelector::networkToName($item['network'], $user_info['url']) != $status["source"]) { + $status["source"] = trim($status["source"].' ('.ContactSelector::networkToName($item['network'], $user_info['url']).')'); } - - // Retweets are only valid for top postings - // It doesn't work reliable with the link if its a feed - //$IsRetweet = ($item['owner-link'] != $item['author-link']); - //if ($IsRetweet) - // $IsRetweet = (($item['owner-name'] != $item['author-name']) || ($item['owner-avatar'] != $item['author-avatar'])); - - if ($item["id"] == $item["parent"]) { $retweeted_item = api_share_as_retweet($item); if ($retweeted_item !== false) { $retweeted_status = $status; try { - $retweeted_status["user"] = api_get_user($a, $retweeted_item["author-link"]); + $retweeted_status["user"] = api_get_user($a, $retweeted_item["author-id"]); } catch (BadRequestException $e) { // user not found. should be found? /// @todo check if the user should be always found @@ -3395,13 +3314,8 @@ function api_lists_statuses($type) $sql_extra .= ' AND `item`.`parent` = ' . intval($conversation_id); } - $statuses = dba::p( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid`, `group_member`.`gid` - FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $statuses = dba::p("SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) STRAIGHT_JOIN `group_member` ON `group_member`.`contact-id` = `item`.`contact-id` WHERE `item`.`uid` = ? AND `verb` = ? @@ -4936,13 +4850,8 @@ function prepare_photo_data($type, $scale, $photo_id) $data['photo']['friendica_activities'] = api_format_items_activities($item[0], $type); // retrieve comments on photo - $r = q( - "SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, - `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, - `contact`.`id` AS `cid` - FROM `item` - STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` = `item`.`uid` + $r = q("SELECT `item`.* FROM `item` + STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND NOT `item`.`deleted` @@ -5254,7 +5163,7 @@ function api_in_reply_to($item) $in_reply_to['status_id_str'] = (string) intval($in_reply_to['status_id']); $r = q( - "SELECT `contact`.`nick`, `contact`.`name`, `contact`.`id`, `contact`.`url` FROM item + "SELECT `contact`.`nick`, `contact`.`name`, `contact`.`id`, `contact`.`url` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`author-id` WHERE `item`.`id` = %d LIMIT 1", intval($in_reply_to['status_id']) From 3f07d01dd1660a9c7b88f0848e5256dd287c79b5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 07:42:56 +0000 Subject: [PATCH 02/21] Get rid of unneeded or redundant fields --- include/conversation.php | 41 ++++++++++++++---------------------- include/enotify.php | 2 +- mod/admin.php | 2 +- mod/display.php | 27 ++++++++++++------------ mod/network.php | 18 +++++----------- mod/ping.php | 7 +----- src/Database/DBStructure.php | 3 --- src/Model/Item.php | 25 ++++++++++------------ src/Object/Post.php | 19 ++++++++--------- 9 files changed, 57 insertions(+), 87 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index b8cdd7a06..6ce200498 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -418,7 +418,6 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`inform`, `item`.`pubmail`, `item`.`visible`, -`item`.`spam`, `item`.`bookmark`, `item`.`unseen`, `item`.`deleted`, @@ -426,10 +425,12 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`mention`, `item`.`global`, `item`.`shadow`, + `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`, + `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, */ - return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`, - `item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, + return "`item`.`author-id`, + `item`.`owner-id`, `item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`, `item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`, `item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`, @@ -441,7 +442,9 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, - `author`.`thumb` AS `author-thumb`, `owner`.`thumb` AS `owner-thumb`, + `author`.`url` AS `author-link`, `author`.`name` AS `author-name`, `author`.`thumb` AS `author-avatar`, + `owner`.`url` AS `owner-link`, `owner`.`name` AS `owner-name`, `owner`.`thumb` AS `owner-avatar`, + `contact`.`url` AS `contact-link`, `contact`.`name` AS `contact-name`, `contact`.`thumb` AS `contact-avatar`, `contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`, @@ -532,7 +535,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = . ((x($_GET, 'bmark')) ? '&bmark=' . $_GET['bmark'] : '') . ((x($_GET, 'liked')) ? '&liked=' . $_GET['liked'] : '') . ((x($_GET, 'conv')) ? '&conv=' . $_GET['conv'] : '') - . ((x($_GET, 'spam')) ? '&spam=' . $_GET['spam'] : '') . ((x($_GET, 'nets')) ? '&nets=' . $_GET['nets'] : '') . ((x($_GET, 'cmin')) ? '&cmin=' . $_GET['cmin'] : '') . ((x($_GET, 'cmax')) ? '&cmax=' . $_GET['cmax'] : '') @@ -658,6 +660,13 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = continue; } + if ($item['network'] == NETWORK_FEED) { + $item['author-avatar'] = $item['contact-avatar']; + $item['author-name'] = $item['contact-name']; + $item['owner-avatar'] = $item['contact-avatar']; + $item['owner-name'] = $item['contact-name']; + } + $profile_name = (strlen($item['author-name']) ? $item['author-name'] : $item['name']); if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; @@ -671,24 +680,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = $sparkle = ' sparkle'; } - if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) { - $author_contact = Contact::getDetailsByURL($item['author-link'], $profile_owner); - if ($author_contact["thumb"]) { - $item['author-thumb'] = $author_contact["thumb"]; - } else { - $item['author-thumb'] = $item['author-avatar']; - } - } - - if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) { - $owner_contact = Contact::getDetailsByURL($item['owner-link'], $profile_owner); - if ($owner_contact["thumb"]) { - $item['owner-thumb'] = $owner_contact["thumb"]; - } else { - $item['owner-thumb'] = $item['owner-avatar']; - } - } - $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; Addon::callHooks('render_location',$locate); @@ -749,7 +740,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = 'name' => $profile_name_e, 'sparkle' => $sparkle, 'lock' => $lock, - 'thumb' => System::removedBaseUrl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), + 'thumb' => System::removedBaseUrl(proxy_url($item['author-avatar'], false, PROXY_SIZE_THUMB)), 'title' => $title_e, 'body' => $body_e, 'tags' => $tags_e, @@ -768,7 +759,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, - 'owner_photo' => System::removedBaseUrl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), + 'owner_photo' => System::removedBaseUrl(proxy_url($item['owner-avatar'], false, PROXY_SIZE_THUMB)), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, diff --git a/include/enotify.php b/include/enotify.php index 39c74fdc6..257c10720 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -152,7 +152,7 @@ function notification($params) } // "your post" - if (DBM::is_result($item) && $item['owner-name'] == $item['author-name'] && $item['wall']) { + if (DBM::is_result($item) && $item['owner-id'] == $item['author-id'] && $item['wall']) { $dest_str = L10n::t('%1$s commented on [url=%2$s]your %3$s[/url]', '[url='.$params['source_link'].']'.$params['source_name'].'[/url]', $itemlink, diff --git a/mod/admin.php b/mod/admin.php index 81c65859c..8e7dfc1f4 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -928,7 +928,7 @@ function admin_page_site_post(App $a) update_table("term", ['url'], $old_url, $new_url); update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url); update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url); - update_table("item", ['owner-link', 'owner-avatar', 'author-link', 'author-avatar', 'body', 'plink', 'tag'], $old_url, $new_url); + update_table("item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url); // update profile addresses in the format "user@server.tld" update_table("contact", ['addr'], $old_host, $new_host); diff --git a/mod/display.php b/mod/display.php index 6286569a5..6380e6f6c 100644 --- a/mod/display.php +++ b/mod/display.php @@ -49,8 +49,7 @@ function display_init(App $a) // Does the local user have this item? if (local_user()) { - $r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`, - `author-avatar`, `network`, `body`, `uid`, `owner-link` + $r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid` FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated` AND `guid` = ? AND `uid` = ? LIMIT 1", $a->argv[1], local_user()); if (DBM::is_result($r)) { @@ -60,8 +59,7 @@ function display_init(App $a) // Is it an item with uid=0? if (!DBM::is_result($r)) { - $r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`, - `author-avatar`, `network`, `body`, `uid`, `owner-link` + $r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid` FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private` AND `uid` = 0 AND `guid` = ? LIMIT 1", $a->argv[1]); @@ -73,8 +71,7 @@ function display_init(App $a) return; } } elseif (($a->argc == 3) && ($nick == 'feed-item')) { - $r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`, - `author-avatar`, `network`, `body`, `uid`, `owner-link` + $r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid` FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private` AND `uid` = 0 AND `id` = ? LIMIT 1", $a->argv[2]); @@ -87,7 +84,7 @@ function display_init(App $a) } if ($r["id"] != $r["parent"]) { - $r = dba::fetch_first("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item` + $r = dba::fetch_first("SELECT `id`, `author-id`, `body`, `uid` FROM `item` WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated` AND `id` = ?", $r["parent"]); } @@ -117,14 +114,16 @@ function display_init(App $a) } function display_fetchauthor($a, $item) { + $author = dba::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]); + $profiledata = []; - $profiledata["uid"] = -1; - $profiledata["nickname"] = $item["author-name"]; - $profiledata["name"] = $item["author-name"]; - $profiledata["picdate"] = ""; - $profiledata["photo"] = $item["author-avatar"]; - $profiledata["url"] = $item["author-link"]; - $profiledata["network"] = $item["network"]; + $profiledata['uid'] = -1; + $profiledata['nickname'] = $author['nick']; + $profiledata['name'] = $author['name']; + $profiledata['picdate'] = ''; + $profiledata['photo'] = $author['photo']; + $profiledata['url'] = $author['url']; + $profiledata['network'] = $author['network']; // Check for a repeated message $skip = false; diff --git a/mod/network.php b/mod/network.php index 23835c8d5..d1a282636 100644 --- a/mod/network.php +++ b/mod/network.php @@ -103,7 +103,6 @@ function network_init(App $a) '/new', //new '', //starred '', //bookmarked - '', //spam ]; $tab_args = [ 'f=&order=comment', //all @@ -112,7 +111,6 @@ function network_init(App $a) '', //new 'f=&star=1', //starred 'f=&bmark=1', //bookmarked - 'f=&spam=1', //spam ]; $k = array_search('active', $last_sel_tabs); @@ -218,9 +216,8 @@ function saved_searches($search) * '/network/new', => $new_active = 'active' * '/network?f=&star=1', => $starred_active = 'active' * '/network?f=&bmark=1', => $bookmarked_active = 'active' - * '/network?f=&spam=1', => $spam_active = 'active' * - * @return Array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); + * @return Array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active); */ function network_query_get_sel_tab(App $a) { @@ -230,7 +227,6 @@ function network_query_get_sel_tab(App $a) $bookmarked_active = ''; $all_active = ''; $conv_active = ''; - $spam_active = ''; $postord_active = ''; if (($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new')) { @@ -249,11 +245,7 @@ function network_query_get_sel_tab(App $a) $conv_active = 'active'; } - if (x($_GET, 'spam')) { - $spam_active = 'active'; - } - - if (($new_active == '') && ($starred_active == '') && ($bookmarked_active == '') && ($conv_active == '') && ($spam_active == '')) { + if (($new_active == '') && ($starred_active == '') && ($bookmarked_active == '') && ($conv_active == '')) { $no_active = 'active'; } @@ -264,7 +256,7 @@ function network_query_get_sel_tab(App $a) } } - return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active]; + return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active]; } function network_query_get_sel_group(App $a) @@ -928,7 +920,7 @@ function network_tabs(App $a) // item filter tabs /// @TODO fix this logic, reduce duplication /// $a->page['content'] .= '
'; - list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a); + list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active) = network_query_get_sel_tab($a); // if no tabs are selected, defaults to comments if ($no_active == 'active') { @@ -1004,7 +996,7 @@ function network_tabs(App $a) // save selected tab, but only if not in file mode if (!x($_GET, 'file')) { PConfig::set(local_user(), 'network.view', 'tab.selected', [ - $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active + $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active ]); } diff --git a/mod/ping.php b/mod/ping.php index 146411206..834577fef 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -442,7 +442,7 @@ function ping_get_notifications($uid) do { $r = q( - "SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted` + "SELECT `notify`.*, `item`.`visible`, `item`.`deleted` FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid` WHERE `notify`.`uid` = %d AND `notify`.`msg` != '' AND NOT (`notify`.`type` IN (%d, %d)) @@ -469,10 +469,6 @@ function ping_get_notifications($uid) $notification["visible"] = true; } - if (is_null($notification["spam"])) { - $notification["spam"] = 0; - } - if (is_null($notification["deleted"])) { $notification["deleted"] = 0; } @@ -495,7 +491,6 @@ function ping_get_notifications($uid) $notification["href"] = System::baseUrl() . "/notify/view/" . $notification["id"]; if ($notification["visible"] - && !$notification["spam"] && !$notification["deleted"] && !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]])) ) { diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 45c98f0ed..03146dd5d 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1185,7 +1185,6 @@ class DBStructure "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"], "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been bookmarked"], "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"], @@ -1196,7 +1195,6 @@ class DBStructure "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"], "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"], - "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], ], "indexes" => [ "PRIMARY" => ["id"], @@ -1681,7 +1679,6 @@ class DBStructure "pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], diff --git a/src/Model/Item.php b/src/Model/Item.php index e6ce67590..1b64aafd0 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -566,6 +566,14 @@ class Item extends BaseObject return 0; } + //unset($item['author-link']); + //unset($item['author-name']); + //unset($item['author-avatar']); + + //unset($item['owner-link']); + unset($item['owner-name']); + unset($item['owner-avatar']); + if ($item['network'] == NETWORK_PHANTOM) { logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG); @@ -716,16 +724,6 @@ class Item extends BaseObject } } - // Is this item available in the global items (with uid=0)? - if ($item["uid"] == 0) { - $item["global"] = true; - - // Set the global flag on all items if this was a global item entry - dba::update('item', ['global' => true], ['uri' => $item["uri"]]); - } else { - $item["global"] = dba::exists('item', ['uid' => 0, 'uri' => $item["uri"]]); - } - // ACL settings if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) { $private = 1; @@ -1483,8 +1481,7 @@ class Item extends BaseObject $forum_mode = ($prvgroup ? 2 : 1); $fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'], - 'owner-id' => $owner_id, 'owner-name' => $self['name'], 'owner-link' => $self['url'], - 'owner-avatar' => $self['thumb'], 'private' => $private, 'allow_cid' => $user['allow_cid'], + 'owner-id' => $owner_id, 'owner-link' => $self['url'], 'private' => $private, 'allow_cid' => $user['allow_cid'], 'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']]; dba::update('item', $fields, ['id' => $item_id]); @@ -2075,7 +2072,7 @@ EOT; private static function addThread($itemid, $onlyshadow = false) { $fields = ['uid', 'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private', 'pubmail', - 'moderated', 'visible', 'spam', 'starred', 'bookmark', 'contact-id', + 'moderated', 'visible', 'starred', 'bookmark', 'contact-id', 'deleted', 'origin', 'forum_mode', 'mention', 'network', 'author-id', 'owner-id']; $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid]; $item = dba::selectFirst('item', $fields, $condition); @@ -2096,7 +2093,7 @@ EOT; private static function updateThread($itemid, $setmention = false) { $fields = ['uid', 'guid', 'title', 'body', 'created', 'edited', 'commented', 'received', 'changed', - 'wall', 'private', 'pubmail', 'moderated', 'visible', 'spam', 'starred', 'bookmark', 'contact-id', + 'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark', 'contact-id', 'deleted', 'origin', 'forum_mode', 'network', 'author-id', 'owner-id', 'rendered-html', 'rendered-hash']; $condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid]; diff --git a/src/Object/Post.php b/src/Object/Post.php index 74dc24b2f..4c2783874 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -198,6 +198,13 @@ class Post extends BaseObject $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false); + if ($item['network'] == NETWORK_FEED) { + $item['author-avatar'] = $item['contact-avatar']; + $item['author-name'] = $item['contact-name']; + $item['owner-avatar'] = $item['contact-avatar']; + $item['owner-name'] = $item['contact-name']; + } + $diff_author = !link_compare($item['url'], $item['author-link']); $profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); if ($item['author-link'] && (!$item['author-name'])) { @@ -209,14 +216,6 @@ class Post extends BaseObject $sparkle = ' sparkle'; } - if (($item['network'] == NETWORK_FEED) || empty($item['author-thumb'])) { - $item['author-thumb'] = $item['author-avatar']; - } - - if (($item['network'] == NETWORK_FEED) || empty($item['owner-thumb'])) { - $item['owner-thumb'] = $item['owner-avatar']; - } - $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; Addon::callHooks('render_location', $locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); @@ -369,7 +368,7 @@ class Post extends BaseObject 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, - 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), + 'thumb' => $a->remove_baseurl(proxy_url($item['author-avatar'], false, PROXY_SIZE_THUMB)), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, @@ -382,7 +381,7 @@ class Post extends BaseObject 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $this->getOwnerUrl(), - 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), + 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-avatar'], false, PROXY_SIZE_THUMB)), 'owner_name' => htmlentities($owner_name_e), 'plink' => get_plink($item), 'edpost' => Feature::isEnabled($conv->getProfileOwner(), 'edit_posts') ? $edpost : '', From 93fd04e38174f84dd2e2c9b6ad3ec3c52680785d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 07:48:13 +0000 Subject: [PATCH 03/21] Removed deprecated functionality --- mod/p.php | 69 ------------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 mod/p.php diff --git a/mod/p.php b/mod/p.php deleted file mode 100644 index 2f69a231e..000000000 --- a/mod/p.php +++ /dev/null @@ -1,69 +0,0 @@ -argc != 2) { - header($_SERVER["SERVER_PROTOCOL"].' 510 '.L10n::t('Not Extended')); - killme(); - } - - $guid = $a->argv[1]; - - if (strtolower(substr($guid, -4)) != ".xml") { - header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found')); - killme(); - } - - $guid = strtolower(substr($guid, 0, -4)); - - // Fetch the item - $item = q("SELECT `uid`, `title`, `body`, `guid`, `contact-id`, `private`, `created`, `app`, `location`, `coord` - FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1", - dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA); - if (!$item) { - $r = q("SELECT `author-link` - FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1", - dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA); - if ($r) { - $parts = parse_url($r[0]["author-link"]); - $host = $parts["scheme"]."://".$parts["host"]; - - if (normalise_link($host) != normalise_link(System::baseUrl())) { - $location = $host."/p/".urlencode($guid).".xml"; - - header("HTTP/1.1 301 Moved Permanently"); - header("Location:".$location); - killme(); - } - } - - header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found')); - killme(); - } - - // Fetch some data from the author (We could combine both queries - but I think this is more readable) - $r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user` - INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self` - WHERE `user`.`uid` = %d", intval($item[0]["uid"])); - if (!DBM::is_result($r)) { - header($_SERVER["SERVER_PROTOCOL"].' 404 '.L10n::t('Not Found')); - killme(); - } - $user = $r[0]; - - $status = Diaspora::buildStatus($item[0], $user); - $xml = Diaspora::buildPostXml($status["type"], $status["message"]); - - header("Content-Type: application/xml; charset=utf-8"); - echo $xml; - - killme(); -} From d7c477d0f457dab689d60bbeeac85944aec6dd31 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 08:36:05 +0000 Subject: [PATCH 04/21] Don't probe anymore, but ensure that we got good contact data --- src/Model/Contact.php | 33 ++++++++++++++++++++++++--------- src/Worker/Notifier.php | 39 ++++++++++++--------------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index f4d6f2af0..bf5b276dd 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -944,21 +944,36 @@ class Contact extends BaseObject 'name' => $data['name'], 'nick' => $data['nick']]; - // Only fill the pubkey if it was empty before. We have to prevent identity theft. - if (!empty($contact['pubkey'])) { - unset($contact['pubkey']); - } else { - $updated['pubkey'] = $data['pubkey']; - } - if ($data['keywords'] != '') { $updated['keywords'] = $data['keywords']; } if ($data['location'] != '') { $updated['location'] = $data['location']; } - if ($data['about'] != '') { - $updated['about'] = $data['about']; + + // Update the technical stuff as well - if filled + if ($data['notify'] != '') { + $updated['notify'] = $data['notify']; + } + if ($data['poll'] != '') { + $updated['poll'] = $data['poll']; + } + if ($data['batch'] != '') { + $updated['batch'] = $data['batch']; + } + if ($data['request'] != '') { + $updated['request'] = $data['request']; + } + if ($data['confirm'] != '') { + $updated['confirm'] = $data['confirm']; + } + if ($data['poco'] != '') { + $updated['poco'] = $data['poco']; + } + + // Only fill the pubkey if it had been empty before. We have to prevent identity theft. + if (empty($contact['pubkey'])) { + $updated['pubkey'] = $data['pubkey']; } if (($data["addr"] != $contact["addr"]) || ($data["alias"] != $contact["alias"])) { diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 11a6f6f68..6ad6827f7 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -164,10 +164,11 @@ class Notifier { if (!in_array($cmd, [Delivery::MAIL, Delivery::SUGGESTION, Delivery::RELOCATION])) { $parent = $items[0]; - $thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d", - dbesc($target_item["thr-parent"]), intval($target_item["uid"])); + $fields = ['network', 'author-id', 'owner-id']; + $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]]; + $thr_parent = dba::selectFirst('item', $fields, $condition); - logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG); + logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG); // This is IMPORTANT!!!! @@ -213,7 +214,7 @@ class Notifier { } // Special treatment for forum posts - if (($target_item['author-link'] != $target_item['owner-link']) && + if (($target_item['author-id'] != $target_item['owner-id']) && ($owner['id'] != $target_item['contact-id']) && ($target_item['uri'] === $target_item['parent-uri'])) { @@ -247,7 +248,7 @@ class Notifier { $target_item['deny_cid'].$target_item['deny_gid']) == 0)) $push_notify = true; - if (($thr_parent && ($thr_parent[0]['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) { + if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) { $push_notify = true; if ($parent["network"] == NETWORK_OSTATUS) { @@ -333,37 +334,21 @@ class Notifier { // If the thread parent is OStatus then do some magic to distribute the messages. // We have not only to look at the parent, since it could be a Friendica thread. - if (($thr_parent && ($thr_parent[0]['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) { + if (($thr_parent && ($thr_parent['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) { $diaspora_delivery = false; - logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent[0]['author-link']." - Owner: ".$thr_parent[0]['owner-link'], LOGGER_DEBUG); + logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent['author-id']." - Owner: ".$thr_parent['owner-id'], LOGGER_DEBUG); // Send a salmon to the parent author - $r = q("SELECT `url`, `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''", - dbesc(normalise_link($thr_parent[0]['author-link'])), - intval($uid)); - if (DBM::is_result($r)) { - $probed_contact = $r[0]; - } else { - $probed_contact = Probe::uri($thr_parent[0]['author-link']); - } - - if ($probed_contact["notify"] != "") { + $probed_contact = dba::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['author-id']]); + if (DBM::is_result($probed_contact) && !empty($probed_contact["notify"])) { logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]); $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"]; } // Send a salmon to the parent owner - $r = q("SELECT `url`, `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''", - dbesc(normalise_link($thr_parent[0]['owner-link'])), - intval($uid)); - if (DBM::is_result($r)) { - $probed_contact = $r[0]; - } else { - $probed_contact = Probe::uri($thr_parent[0]['owner-link']); - } - - if ($probed_contact["notify"] != "") { + $probed_contact = dba::selectFirst('contact', ['url', 'notify'], ['id' => $thr_parent['owner-id']]); + if (DBM::is_result($probed_contact) && !empty($probed_contact["notify"])) { logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]); $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"]; } From f081f150962f168e1408e6b411c0da0e42406acd Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 08:46:23 +0000 Subject: [PATCH 05/21] Updated sql file --- database.sql | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index cc6ab16e1..6f4d9ca79 100644 --- a/database.sql +++ b/database.sql @@ -465,7 +465,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `extid` varchar(255) NOT NULL DEFAULT '' COMMENT '', `thr-parent` varchar(255) NOT NULL DEFAULT '' COMMENT 'If the parent of this item is not the top-level item in the conversation, the uri of the immediate parent; otherwise set to parent-uri', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation timestamp.', - `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)', + `edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last edit (default is created)', `commented` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date of last comment/reply to this item', `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime', `changed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Date that something in the conversation changed, indicating clients should fetch the conversation again', @@ -487,7 +487,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `target-type` varchar(100) NOT NULL DEFAULT '' COMMENT 'ActivityStreams target type if applicable (URI)', `target` text COMMENT 'JSON encoded target structure if used', `postopts` text COMMENT 'External post connectors add their network name to this comma-separated string to identify that they should be delivered to these networks during delivery', - `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL toa displayable copy of the message at its source', + `plink` varchar(255) NOT NULL DEFAULT '' COMMENT 'permalink or URL to a displayable copy of the message at its source', `resource-id` varchar(32) NOT NULL DEFAULT '' COMMENT 'Used to link other tables to items, it identifies the linked resource (e.g. photo) and if set must also set resource_type', `event-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Used to link to the event.id', `tag` mediumtext COMMENT '', @@ -504,7 +504,6 @@ CREATE TABLE IF NOT EXISTS `item` ( `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '', `moderated` boolean NOT NULL DEFAULT '0' COMMENT '', `visible` boolean NOT NULL DEFAULT '0' COMMENT '', - `spam` boolean NOT NULL DEFAULT '0' COMMENT '', `starred` boolean NOT NULL DEFAULT '0' COMMENT 'item has been favourited', `bookmark` boolean NOT NULL DEFAULT '0' COMMENT 'item has been bookmarked', `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'item has not been seen', @@ -515,7 +514,6 @@ CREATE TABLE IF NOT EXISTS `item` ( `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from', `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '', `rendered-html` mediumtext COMMENT 'item.body converted to html', - `global` boolean NOT NULL DEFAULT '0' COMMENT '', PRIMARY KEY(`id`), INDEX `guid` (`guid`(191)), INDEX `uri` (`uri`(191)), @@ -976,7 +974,6 @@ CREATE TABLE IF NOT EXISTS `thread` ( `pubmail` boolean NOT NULL DEFAULT '0' COMMENT '', `moderated` boolean NOT NULL DEFAULT '0' COMMENT '', `visible` boolean NOT NULL DEFAULT '0' COMMENT '', - `spam` boolean NOT NULL DEFAULT '0' COMMENT '', `starred` boolean NOT NULL DEFAULT '0' COMMENT '', `ignored` boolean NOT NULL DEFAULT '0' COMMENT '', `bookmark` boolean NOT NULL DEFAULT '0' COMMENT '', @@ -1082,7 +1079,7 @@ CREATE TABLE IF NOT EXISTS `userd` ( CREATE TABLE IF NOT EXISTS `user-item` ( `iid` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item id', `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id', - `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Hidden marker', + `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user', PRIMARY KEY(`uid`,`iid`) ) DEFAULT COLLATE utf8mb4_general_ci; From d76fb6d0b9936d56250b60102a5fb839b057e772 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 09:19:27 +0000 Subject: [PATCH 06/21] Fixed SQL error --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index 54176da79..2892dfe4e 100644 --- a/include/api.php +++ b/include/api.php @@ -2066,7 +2066,7 @@ function api_conversation_show($type) $sql_extra = ' AND `item`.`id` <= ' . intval($max_id); } - $r = q("SELECT `* FROM `item` + $r = q("SELECT `item`.`*` FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` From ea498ff283d660c1b5a6222f43a212564fc8755d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 09:21:48 +0000 Subject: [PATCH 07/21] And a second SQL error fixed --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index 2892dfe4e..4dce85ed5 100644 --- a/include/api.php +++ b/include/api.php @@ -1632,7 +1632,7 @@ function api_search($type) $r = dba::p( "SELECT ".item_fieldlists()." FROM `item` ".item_joins(api_user())." - WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`)) + WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`public`)) AND `item`.`body` LIKE CONCAT('%',?,'%') $sql_extra AND `item`.`id`>? From b654af28fa417459b14289036cdac0c6a7844b9e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 09:40:32 +0000 Subject: [PATCH 08/21] We need "global" --- database.sql | 1 + include/api.php | 4 ++-- src/Database/DBStructure.php | 1 + src/Model/Item.php | 10 ++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/database.sql b/database.sql index 6f4d9ca79..ffe02585e 100644 --- a/database.sql +++ b/database.sql @@ -514,6 +514,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `network` char(4) NOT NULL DEFAULT '' COMMENT 'Network from where the item comes from', `rendered-hash` varchar(32) NOT NULL DEFAULT '' COMMENT '', `rendered-html` mediumtext COMMENT 'item.body converted to html', + `global` boolean NOT NULL DEFAULT '0' COMMENT '', PRIMARY KEY(`id`), INDEX `guid` (`guid`(191)), INDEX `uri` (`uri`(191)), diff --git a/include/api.php b/include/api.php index 4dce85ed5..94adecf0c 100644 --- a/include/api.php +++ b/include/api.php @@ -1632,7 +1632,7 @@ function api_search($type) $r = dba::p( "SELECT ".item_fieldlists()." FROM `item` ".item_joins(api_user())." - WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`public`)) + WHERE ".item_condition()." AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`)) AND `item`.`body` LIKE CONCAT('%',?,'%') $sql_extra AND `item`.`id`>? @@ -2066,7 +2066,7 @@ function api_conversation_show($type) $sql_extra = ' AND `item`.`id` <= ' . intval($max_id); } - $r = q("SELECT `item`.`*` FROM `item` + $r = q("SELECT `item`.* FROM `item` STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND (NOT `contact`.`blocked` OR `contact`.`pending`) WHERE `item`.`parent` = %d AND `item`.`visible` diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 03146dd5d..f5c778b21 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1195,6 +1195,7 @@ class DBStructure "network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"], "rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""], "rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"], + "global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], ], "indexes" => [ "PRIMARY" => ["id"], diff --git a/src/Model/Item.php b/src/Model/Item.php index 1b64aafd0..c15d10f19 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -724,6 +724,16 @@ class Item extends BaseObject } } + // Is this item available in the global items (with uid=0)? + if ($item["uid"] == 0) { + $item["global"] = true; + + // Set the global flag on all items if this was a global item entry + dba::update('item', ['global' => true], ['uri' => $item["uri"]]); + } else { + $item["global"] = dba::exists('item', ['uid' => 0, 'uri' => $item["uri"]]); + } + // ACL settings if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) { $private = 1; From 6985ad4fb5a3f60a3bbc7fb456e83911dd78d1fd Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 09:55:41 +0000 Subject: [PATCH 09/21] Improved error message --- include/api.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/api.php b/include/api.php index 94adecf0c..e93f44f2e 100644 --- a/include/api.php +++ b/include/api.php @@ -532,7 +532,7 @@ function api_get_user(App $a, $contact_id = null) $user = dbesc(api_unique_id_to_nurl(intval($contact_id))); if ($user == "") { - throw new BadRequestException("User not found."); + throw new BadRequestException("User ID ".$contact_id." not found."); } $url = $user; @@ -546,7 +546,7 @@ function api_get_user(App $a, $contact_id = null) $user = dbesc(api_unique_id_to_nurl($_GET['user_id'])); if ($user == "") { - throw new BadRequestException("User not found."); + throw new BadRequestException("User ID ".$_GET['user_id']." not found."); } $url = $user; @@ -677,7 +677,7 @@ function api_get_user(App $a, $contact_id = null) return $ret; } else { - throw new BadRequestException("User not found."); + throw new BadRequestException("User ".$url." not found."); } } @@ -1541,10 +1541,10 @@ function api_users_search($type) } $userlist = ["users" => $userlist]; } else { - throw new BadRequestException("User not found."); + throw new BadRequestException("User ".$_GET["q"]." not found."); } } else { - throw new BadRequestException("User not found."); + throw new BadRequestException("No user specified."); } return api_format_data("users", $type, $userlist); From 96d170c9d8d9872dfcbb024d7c0d36977df34e6c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 10:04:02 +0000 Subject: [PATCH 10/21] Trying to understand the test tool --- tests/ApiTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ApiTest.php b/tests/ApiTest.php index f0e27b4af..d3ab50350 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -74,6 +74,7 @@ class ApiTest extends DatabaseTest { $this->assertEquals($this->selfUser['id'], $user['uid']); $this->assertEquals($this->selfUser['id'], $user['cid']); + $this->assertEquals($this->selfUser['id'], $user['pid']); $this->assertEquals(1, $user['self']); $this->assertEquals('Friendica', $user['location']); $this->assertEquals($this->selfUser['name'], $user['name']); From 28678c0fad5f43c350618292c16c6334a759292c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 10:22:10 +0000 Subject: [PATCH 11/21] Reverting the last test --- tests/ApiTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ApiTest.php b/tests/ApiTest.php index d3ab50350..f0e27b4af 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -74,7 +74,6 @@ class ApiTest extends DatabaseTest { $this->assertEquals($this->selfUser['id'], $user['uid']); $this->assertEquals($this->selfUser['id'], $user['cid']); - $this->assertEquals($this->selfUser['id'], $user['pid']); $this->assertEquals(1, $user['self']); $this->assertEquals('Friendica', $user['location']); $this->assertEquals($this->selfUser['name'], $user['name']); From 443d828ba727a1e9ff1dbdb0784ad03652de9b1f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 10:29:42 +0000 Subject: [PATCH 12/21] We don't need to look for the uid --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/api.php b/include/api.php index e93f44f2e..de5c5689f 100644 --- a/include/api.php +++ b/include/api.php @@ -492,7 +492,7 @@ function api_rss_extra(App $a, $arr, $user_info) */ function api_unique_id_to_nurl($id) { - $r = dba::selectFirst('contact', ['nurl'], ['uid' => 0, 'id' => $id]); + $r = dba::selectFirst('contact', ['nurl'], ['id' => $id]); if (DBM::is_result($r)) { return $r["nurl"]; From b33578c137f6a067afa334f7f80d439da8ebb9bf Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 10:47:40 +0000 Subject: [PATCH 13/21] Additional data for the test tool --- tests/datasets/api.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index ae1fd3242..9da5bf370 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -74,6 +74,7 @@ item: author-link: http://localhost/profile/selfcontact wall: true starred: true + private: false allow_cid: '' allow_gid: '' deny_cid: '' @@ -134,6 +135,7 @@ item: author-link: http://localhost/profile/othercontact wall: true starred: false + private: false allow_cid: '' allow_gid: '' deny_cid: '' From e392491e94cf81a53444ac189e8eb8448de13eb5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 10:58:03 +0000 Subject: [PATCH 14/21] Next try ;-) --- tests/datasets/api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index 9da5bf370..4c385dacc 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -74,7 +74,7 @@ item: author-link: http://localhost/profile/selfcontact wall: true starred: true - private: false + private: 0 allow_cid: '' allow_gid: '' deny_cid: '' @@ -135,7 +135,7 @@ item: author-link: http://localhost/profile/othercontact wall: true starred: false - private: false + private: 0 allow_cid: '' allow_gid: '' deny_cid: '' From 058d755372aea141e93d2422c67505d97e963fc7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:07:24 +0000 Subject: [PATCH 15/21] I guess I broke the test tool :-) --- tests/datasets/api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index 4c385dacc..14ea3178b 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -74,7 +74,7 @@ item: author-link: http://localhost/profile/selfcontact wall: true starred: true - private: 0 + private: '0' allow_cid: '' allow_gid: '' deny_cid: '' @@ -135,7 +135,7 @@ item: author-link: http://localhost/profile/othercontact wall: true starred: false - private: 0 + private: '0' allow_cid: '' allow_gid: '' deny_cid: '' From e48b2a3dad2ce90927cb6435611f747cce3f9e5f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:12:09 +0000 Subject: [PATCH 16/21] Reverting it ... --- tests/datasets/api.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index 14ea3178b..ae1fd3242 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -74,7 +74,6 @@ item: author-link: http://localhost/profile/selfcontact wall: true starred: true - private: '0' allow_cid: '' allow_gid: '' deny_cid: '' @@ -135,7 +134,6 @@ item: author-link: http://localhost/profile/othercontact wall: true starred: false - private: '0' allow_cid: '' allow_gid: '' deny_cid: '' From 9ade6c2b33834efea5892317795298a47f802cd3 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:20:22 +0000 Subject: [PATCH 17/21] The testdata hadn't contained public contacts --- tests/datasets/api.yml | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index ae1fd3242..5955af0ec 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -58,14 +58,40 @@ contact: blocked: false rel: 2 network: dfrn + - + id: 45 + uid: 0 + name: Self contact + nick: selfcontact + self: true + nurl: http://localhost/profile/selfcontact + url: http://localhost/profile/selfcontact + about: User used in tests + pending: false + blocked: false + rel: 0 + network: dfrn + - + id: 46 + uid: 0 + name: Friend contact + nick: friendcontact + self: false + nurl: http://localhost/profile/friendcontact + url: http://localhost/profile/friendcontact + pending: false + blocked: false + rel: 0 + network: dfrn + - item: - id: 1 visible: true contact-id: 42 - author-id: 42 - owner-id: 42 + author-id: 45 + owner-id: 45 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: true @@ -82,8 +108,8 @@ item: id: 2 visible: true contact-id: 42 - author-id: 42 - owner-id: 42 + author-id: 45 + owner-id: 45 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: false From 946bfd79ff3ccf8fe32bdda17222a037820351d4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:29:09 +0000 Subject: [PATCH 18/21] Just one more ... --- tests/datasets/api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index 5955af0ec..e5c51c886 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -63,7 +63,7 @@ contact: uid: 0 name: Self contact nick: selfcontact - self: true + self: false nurl: http://localhost/profile/selfcontact url: http://localhost/profile/selfcontact about: User used in tests From e232ccf9e033595455eef213e5c155a26303dc11 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:38:03 +0000 Subject: [PATCH 19/21] Trying around ... --- tests/datasets/api.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index e5c51c886..ce66e7c32 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -90,8 +90,8 @@ item: id: 1 visible: true contact-id: 42 - author-id: 45 - owner-id: 45 + author-id: 42 + owner-id: 42 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: true @@ -108,8 +108,8 @@ item: id: 2 visible: true contact-id: 42 - author-id: 45 - owner-id: 45 + author-id: 42 + owner-id: 42 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: false From 09c1b44381d9a0f6e93790ac8c8140659ce749bd Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 11:42:23 +0000 Subject: [PATCH 20/21] Someone else has to fix this --- tests/datasets/api.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index ce66e7c32..ae1fd3242 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -58,32 +58,6 @@ contact: blocked: false rel: 2 network: dfrn - - - id: 45 - uid: 0 - name: Self contact - nick: selfcontact - self: false - nurl: http://localhost/profile/selfcontact - url: http://localhost/profile/selfcontact - about: User used in tests - pending: false - blocked: false - rel: 0 - network: dfrn - - - id: 46 - uid: 0 - name: Friend contact - nick: friendcontact - self: false - nurl: http://localhost/profile/friendcontact - url: http://localhost/profile/friendcontact - pending: false - blocked: false - rel: 0 - network: dfrn - - item: - From f316e96bd1e8e3ce7447a23b054c7b7f665418eb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 3 Jun 2018 16:11:05 +0000 Subject: [PATCH 21/21] Now the dataset is said to be valid again. --- tests/datasets/api.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/datasets/api.yml b/tests/datasets/api.yml index ae1fd3242..9cacab714 100644 --- a/tests/datasets/api.yml +++ b/tests/datasets/api.yml @@ -65,7 +65,7 @@ item: visible: true contact-id: 42 author-id: 42 - owner-id: 42 + owner-id: 45 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: true @@ -83,7 +83,7 @@ item: visible: true contact-id: 42 author-id: 42 - owner-id: 42 + owner-id: 45 uid: 42 verb: http://activitystrea.ms/schema/1.0/post unseen: false