- // 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);
- }
-
- return $message_id;