Item distribution is now done via the public post
This commit is contained in:
parent
7230cc0bed
commit
5cf745af44
4 changed files with 102 additions and 59 deletions
|
@ -2773,6 +2773,10 @@ class DFRN
|
|||
if ($posted_id) {
|
||||
logger("Reply from contact ".$item["contact-id"]." was stored with id ".$posted_id, LOGGER_DEBUG);
|
||||
|
||||
IF ($item['uid'] == 0) {
|
||||
Item::distribute($posted_id);
|
||||
}
|
||||
|
||||
$item["id"] = $posted_id;
|
||||
|
||||
$r = q(
|
||||
|
@ -2827,6 +2831,10 @@ class DFRN
|
|||
|
||||
logger("Item was stored with id ".$posted_id, LOGGER_DEBUG);
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
Item::distribute($posted_id);
|
||||
}
|
||||
|
||||
if (stristr($item["verb"], ACTIVITY_POKE)) {
|
||||
self::doPoke($item, $importer, $posted_id);
|
||||
}
|
||||
|
|
|
@ -590,57 +590,13 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!($postdata = self::validPosting($msg))) {
|
||||
if (!($fields = self::validPosting($msg))) {
|
||||
logger("Invalid posting");
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = $postdata['fields'];
|
||||
|
||||
// Is it a an action (comment, like, ...) for our own post?
|
||||
if (isset($fields->parent_guid) && !$postdata["relayed"]) {
|
||||
$guid = notags(unxmlify($fields->parent_guid));
|
||||
$importer = self::importerForGuid($guid);
|
||||
if (is_array($importer)) {
|
||||
logger("delivering to origin: ".$importer["name"]);
|
||||
$message_id = self::dispatch($importer, $msg, $fields);
|
||||
return $message_id;
|
||||
}
|
||||
}
|
||||
|
||||
// Process item retractions. This has to be done separated from the other stuff,
|
||||
// since retractions for comments could come even from non followers.
|
||||
if (!empty($fields) && in_array($fields->getName(), ['retraction'])) {
|
||||
$target = notags(unxmlify($fields->target_type));
|
||||
if (in_array($target, ["Comment", "Like", "Post", "Reshare", "StatusMessage"])) {
|
||||
logger('processing retraction for '.$target, LOGGER_DEBUG);
|
||||
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
|
||||
$message_id = self::dispatch($importer, $msg, $fields);
|
||||
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')
|
||||
AND NOT `account_expired` AND NOT `account_removed`",
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
dbesc($msg["author"])
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
logger("delivering to: ".$rr["username"]);
|
||||
self::dispatch($rr, $msg, $fields);
|
||||
}
|
||||
} elseif (!Config::get('system', 'relay_subscribe', false)) {
|
||||
logger("Unwanted message from ".$msg["author"]." 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
|
||||
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
|
||||
$message_id = self::dispatch($importer, $msg, $fields);
|
||||
}
|
||||
$importer = ["uid" => 0, "page-flags" => PAGE_FREELOVE];
|
||||
$message_id = self::dispatch($importer, $msg, $fields);
|
||||
|
||||
return $message_id;
|
||||
}
|
||||
|
@ -662,11 +618,10 @@ class Diaspora
|
|||
|
||||
// This is only needed for private postings since this is already done for public ones before
|
||||
if (is_null($fields)) {
|
||||
if (!($postdata = self::validPosting($msg))) {
|
||||
if (!($fields = self::validPosting($msg))) {
|
||||
logger("Invalid posting");
|
||||
return false;
|
||||
}
|
||||
$fields = $postdata['fields'];
|
||||
}
|
||||
|
||||
$type = $fields->getName();
|
||||
|
@ -840,7 +795,7 @@ class Diaspora
|
|||
|
||||
// Only some message types have signatures. So we quit here for the other types.
|
||||
if (!in_array($type, ["comment", "like"])) {
|
||||
return ["fields" => $fields, "relayed" => false];
|
||||
return $fields;
|
||||
}
|
||||
// No author_signature? This is a must, so we quit.
|
||||
if (!isset($author_signature)) {
|
||||
|
@ -849,16 +804,12 @@ class Diaspora
|
|||
}
|
||||
|
||||
if (isset($parent_author_signature)) {
|
||||
$relayed = true;
|
||||
|
||||
$key = self::key($msg["author"]);
|
||||
|
||||
if (!Crypto::rsaVerify($signed_data, $parent_author_signature, $key, "sha256")) {
|
||||
logger("No valid parent author signature for parent author ".$msg["author"]. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$parent_author_signature, LOGGER_DEBUG);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$relayed = false;
|
||||
}
|
||||
|
||||
$key = self::key($fields->author);
|
||||
|
@ -867,7 +818,7 @@ class Diaspora
|
|||
logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);
|
||||
return false;
|
||||
} else {
|
||||
return ["fields" => $fields, "relayed" => $relayed];
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1836,6 +1787,9 @@ class Diaspora
|
|||
|
||||
if ($message_id) {
|
||||
logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
if ($datarray['uid'] == 0) {
|
||||
Item::distribute($message_id);
|
||||
}
|
||||
}
|
||||
|
||||
// If we are the origin of the parent we store the original data and notify our followers
|
||||
|
@ -2157,6 +2111,9 @@ class Diaspora
|
|||
|
||||
if ($message_id) {
|
||||
logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
if ($datarray['uid'] == 0) {
|
||||
Item::distribute($message_id);
|
||||
}
|
||||
}
|
||||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
|
@ -2883,6 +2840,9 @@ class Diaspora
|
|||
|
||||
if ($message_id) {
|
||||
logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
if ($datarray['uid'] == 0) {
|
||||
Item::distribute($message_id);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -3107,6 +3067,9 @@ class Diaspora
|
|||
|
||||
if ($message_id) {
|
||||
logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG);
|
||||
if ($datarray['uid'] == 0) {
|
||||
Item::distribute($message_id);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue