From bd21fc3751c76bc62893cd6e8e69f949f9e0d475 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 27 Apr 2018 21:08:19 -0400 Subject: [PATCH 1/3] Import posts from ignored contacts --- src/Model/Item.php | 2 +- src/Protocol/DFRN.php | 4 ---- src/Protocol/Diaspora.php | 2 +- src/Worker/OnePoll.php | 4 ++-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index e7fd115dd1..54abc49d60 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -872,7 +872,7 @@ class Item extends BaseObject $users = []; - $condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND NOT `readonly` AND `rel` IN (?, ?)", + $condition = ["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `id` = ?) AND `uid` != 0 AND NOT `blocked` AND `rel` IN (?, ?)", $parent['owner-id'], CONTACT_IS_SHARING, CONTACT_IS_FRIEND]; $contacts = dba::select('contact', ['uid'], $condition); while ($contact = dba::fetch($contacts)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index f233f158a9..ad7658a764 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2799,10 +2799,6 @@ class DFRN return true; } } else { // $entrytype == DFRN_TOP_LEVEL - if ($importer["readonly"]) { - logger('ignoring read-only contact '.$importer["id"]); - return; - } if (($importer["uid"] == 0) && ($importer["importer_uid"] != 0)) { logger("Contact ".$importer["id"]." isn't known to user ".$importer["importer_uid"].". The post will be ignored.", LOGGER_DEBUG); return; diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 61d1a586fa..f4a649b51c 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1151,7 +1151,7 @@ class Diaspora //} // We don't seem to like that person - if ($contact["blocked"] || $contact["readonly"]) { + if ($contact["blocked"]) { // Maybe blocked, don't accept. return false; // We are following this person? diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index c1c6fdd1a8..aa3eabf57d 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -309,7 +309,7 @@ class OnePoll // Are we allowed to import from this person? - if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked'] || $contact['readonly']) { + if ($contact['rel'] == CONTACT_IS_FOLLOWER || $contact['blocked']) { // set the last-update so we don't keep polling dba::update('contact', ['last-update' => DateTimeFormat::utcNow()], ['id' => $contact['id']]); return; @@ -590,7 +590,7 @@ class OnePoll } $hubmode = 'subscribe'; - if ($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly']) { + if ($contact['network'] === NETWORK_DFRN || $contact['blocked']) { $hubmode = 'unsubscribe'; } From c417f779c4660bdc47a124ed2343e2502fbcc02d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 28 Apr 2018 07:47:02 -0400 Subject: [PATCH 2/3] Add missing readonly check for displaying items in item_joins --- include/conversation.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 41f10959b2..bd3481670e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -470,11 +470,14 @@ These Fields are not added below (yet). They are here to for bug search. * @brief SQL join for contacts that are needed for displaying items */ function item_joins() { - return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND - (NOT `contact`.`blocked` OR `contact`.`pending`) + return sprintf("STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + AND `contact`.`rel` IN (%s, %s) + AND NOT (`contact`.`blocked` OR `contact`.`readonly` OR `contact`.`pending`) LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id` - LEFT JOIN `event` ON `event-id` = `event`.`id`"; + LEFT JOIN `event` ON `event-id` = `event`.`id`", + CONTACT_IS_SHARING, CONTACT_IS_FRIEND + ); } /** From 9edff6cc5c0ac1c5127499663a010bb723ebacca Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 28 Apr 2018 11:38:01 -0400 Subject: [PATCH 3/3] Add exception for self-contact in item_joins() --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index bd3481670e..85f6547340 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -471,7 +471,7 @@ These Fields are not added below (yet). They are here to for bug search. */ function item_joins() { return sprintf("STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND `contact`.`rel` IN (%s, %s) + AND (`contact`.`rel` IN (%s, %s) OR `contact`.`self`) AND NOT (`contact`.`blocked` OR `contact`.`readonly` OR `contact`.`pending`) LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`