return $contact_id;
}
+/**
+ * @brief Checks if the contact is blocked
+ *
+ * @param int $cid contact id
+ *
+ * @return boolean Is the contact blocked?
+ */
+function blockedContact($cid) {
+ if ($cid == 0) {
+ return false;
+ }
+
+ $blocked = dba::select('contact', array('blocked'), array('id' => $cid), array('limit' => 1));
+ if (!dbm::is_result($blocked)) {
+ return false;
+ }
+ return (bool)$blocked['blocked'];
+}
+
+/**
+ * @brief Checks if the contact is hidden
+ *
+ * @param int $cid contact id
+ *
+ * @return boolean Is the contact hidden?
+ */
+function hiddenContact($cid) {
+ if ($cid == 0) {
+ return false;
+ }
+
+ $hidden = dba::select('contact', array('hidden'), array('id' => $cid), array('limit' => 1));
+ if (!dbm::is_result($hidden)) {
+ return false;
+ }
+ return (bool)$hidden['hidden'];
+}
+
/**
* @brief Returns posts from a given gcontact
*
$arr["author-id"] = get_contact($arr["author-link"], 0);
}
+ if (blockedContact($arr["author-id"])) {
+ logger('Contact '.$arr["author-id"].' is blocked, item '.$arr["uri"].' will not be stored');
+ return 0;
+ }
+
if ($arr["owner-id"] == 0) {
$arr["owner-id"] = get_contact($arr["owner-link"], 0);
}
+ if (blockedContact($arr["owner-id"])) {
+ logger('Contact '.$arr["owner-id"].' is blocked, item '.$arr["uri"].' will not be stored');
+ return 0;
+ }
+
if ($arr['guid'] != "") {
// Checking if there is already an item with the same guid
logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG);
* @param integer $itemid Item ID that should be added
*/
function add_shadow_thread($itemid) {
- $items = q("SELECT `uid`, `wall`, `private`, `moderated`, `visible`, `contact-id`, `deleted`, `network`
+ $items = q("SELECT `uid`, `wall`, `private`, `moderated`, `visible`, `contact-id`, `deleted`, `network`, `author-id`, `owner-id`
FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!dbm::is_result($items)) {
return;
}
+ // Is the public contact configured as hidden?
+ if (hiddenContact($item["owner-id"]) || hiddenContact($item["author-id"])) {
+ return;
+ }
+
// Only do these checks if the post isn't a wall post
if (!$item["wall"]) {
// Check, if hide-friends is activated - then don't do a shadow entry