Comments from unknown people never reached us
This commit is contained in:
parent
6882b5cda9
commit
f639a86d02
1 changed files with 34 additions and 8 deletions
|
@ -347,15 +347,10 @@ class Diaspora {
|
||||||
self::dispatch($rr,$msg);
|
self::dispatch($rr,$msg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$social_relay = (bool)Config::get('system', 'relay_subscribe', false);
|
|
||||||
|
|
||||||
// Use a dummy importer to import the data for the public copy
|
// Use a dummy importer to import the data for the public copy
|
||||||
if ($social_relay) {
|
// or for comments from unknown people
|
||||||
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
|
$importer = array("uid" => 0, "page-flags" => PAGE_FREELOVE);
|
||||||
$message_id = self::dispatch($importer,$msg);
|
$message_id = self::dispatch($importer,$msg);
|
||||||
} else {
|
|
||||||
logger("Unwanted message from ".$msg["author"]." send by ".$_SERVER["REMOTE_ADDR"]." with ".$_SERVER["HTTP_USER_AGENT"].": ".print_r($msg, true), LOGGER_DEBUG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message_id;
|
return $message_id;
|
||||||
|
@ -382,6 +377,11 @@ class Diaspora {
|
||||||
|
|
||||||
$type = $fields->getName();
|
$type = $fields->getName();
|
||||||
|
|
||||||
|
$social_relay = Config::get('system', 'relay_subscribe', false);
|
||||||
|
if (!$social_relay AND ($type == 'message')) {
|
||||||
|
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);
|
logger("Received message type ".$type." from ".$sender." for user ".$importer["uid"], LOGGER_DEBUG);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
@ -1227,6 +1227,27 @@ class Diaspora {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Find the best importer for a comment
|
||||||
|
*
|
||||||
|
* @param array $importer Array of the importer user
|
||||||
|
* @param string $guid The guid of the item
|
||||||
|
*
|
||||||
|
* @return array the importer that fits the best
|
||||||
|
*/
|
||||||
|
private static function importer_for_comment($importer, $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 $importer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Processes an incoming comment
|
* @brief Processes an incoming comment
|
||||||
*
|
*
|
||||||
|
@ -1256,6 +1277,11 @@ class Diaspora {
|
||||||
$thr_uri = "";
|
$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);
|
$contact = self::allowed_contact_by_handle($importer, $sender, true);
|
||||||
if (!$contact) {
|
if (!$contact) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue