return false;
}
+ if (!self::valid_posting($msg, $fields)) {
+ logger("Invalid posting");
+ return false;
+ }
+
+ // Is it a an action (comment, like, ...) for our own post?
+ if (isset($fields->parent_guid)) {
+ $guid = notags(unxmlify($fields->parent_guid));
+
+ $importer = self::importer_for_guid($guid);
+ if (is_array($importer)) {
+ logger("delivering to origin: ".$importer["name"]);
+ $message_id = self::dispatch($importer, $msg);
+ return $message_id;
+ }
+ }
+
// Now distribute it to the followers
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN
(SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s')
logger("delivering to: ".$rr["username"]);
self::dispatch($rr, $msg);
}
+ } elseif (!Config::get('system', 'relay_subscribe', false)) {
+ logger("Unwanted message from ".$sender." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
} else {
// Use a dummy importer to import the data for the public copy
- // or for comments from unknown people
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
$message_id = self::dispatch($importer, $msg);
}
$type = $fields->getName();
- $social_relay = Config::get('system', 'relay_subscribe', false);
- if (!$social_relay AND (in_array($type, array('status_message', 'reshare')))) {
- logger("Unwanted message from ".$sender." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
- }
-
logger("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG);
switch ($type) {
logger("defining user ".$contact["nick"]." as friend");
}
+ // We don't seem to like that person
if ($contact["blocked"] || $contact["readonly"] || $contact["archive"]) {
return false;
+ // We are following this person? Then it is okay
} elseif (($contact["rel"] == CONTACT_IS_SHARING) || ($contact["rel"] == CONTACT_IS_FRIEND)) {
return true;
+ // Is it a post to a community? That's good
} elseif (($contact["rel"] == CONTACT_IS_FOLLOWER) && ($importer["page-flags"] == PAGE_COMMUNITY)) {
return true;
}
if ($is_comment) {
return $importer;
} else {
- return true;
+ return false;
}
}
}
/**
- * @brief Find the best importer for a comment
+ * @brief Find the best importer for a comment, like, ...
*
- * @param array $importer Array of the importer user
* @param string $guid The guid of the item
*
- * @return array the importer that fits the best
+ * @return array|boolean the origin owner of that post - or false
*/
- private static function importer_for_comment($importer, $guid) {
+ private static function importer_for_guid($guid) {
$item = dba::fetch_first("SELECT `uid` FROM `item` WHERE `origin` AND `guid` = ? LIMIT 1", $guid);
if (dbm::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `self` AND `uid` = ?", $item['uid']);
if (dbm::is_result($contact)) {
- $importer = $contact;
+ return $contact;
}
}
- return $importer;
+ return false;
}
/**
$thr_uri = "";
}
- // Find the best importer when there was no importer found
- if ($importer["uid"] == 0) {
- $importer = self::importer_for_comment($importer, $parent_guid);
- }
-
$contact = self::allowed_contact_by_handle($importer, $sender, true);
if (!$contact) {
return false;
if (!in_array($parent_type, array("Post", "Comment")))
return false;
- // Find the best importer when there was no importer found
- if ($importer["uid"] == 0) {
- $importer = self::importer_for_comment($importer, $parent_guid);
- }
-
$contact = self::allowed_contact_by_handle($importer, $sender, true);
if (!$contact)
return false;