Ejemplo n.º 1
0
function hunt_postman_fn($job)
{
    clog("gearman Received hunt_postman command");
    // Send items out
    $col = \App\DB\Get::Collection();
    $res2 = $col->outbox->find();
    // TODO: order by priority
    foreach ($res2 as $resItem) {
        $req21 = new \App\Requests\JSON($resItem["message"]["destination"], $resItem["message"]["source"], $resItem["message"]["payload"]);
        // Remove from collection
        $col->outbox->remove(array("_id" => $resItem["_id"]));
        $req21->send(true, $resItem["priority"], $resItem["tries"]);
    }
}
Ejemplo n.º 2
0
 public static function tryToGet($userId, $revision)
 {
     $col = \App\DB\Get::Collection();
     // Check if public key already exists in your servers key directory
     $result = $col->serverKeyDirectory->count(array("userId" => $userId, "revision" => $revision));
     if ($result < 1) {
         clog("KEY NOT FOUND");
         // If not found -> Send request to $userIds server to get the users public key
         $data = array("requests" => array(array("id" => "key_get", "pem" => true, "revision" => $revision, "profileId" => $userId)));
         $jsonRequest = new \App\Requests\JSON($userId, $userId, $data);
         $reqData = $jsonRequest->send();
         if ($reqData["key_get"]["revision"] == $revision) {
             $col->serverKeyDirectory->insert(array("userId" => $userId, "pemkey" => $reqData["key_get"]["pemkey"], "revision" => $revision));
         }
     }
     $result = $col->serverKeyDirectory->findOne(array("userId" => $userId, "revision" => $revision));
     if ($result != null) {
         return $result["pemkey"];
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
     // Type is MongoID!
     $dbReturn2 = $col->posts->findOne(array("_id" => new MongoId($postId)), array("collectionId", "_id"));
     // has field owner
     $dbReturn3 = $col->followers->find(array("collectionId" => new MongoId($dbReturn2["collectionId"])));
     $data = array("requests" => array(array("id" => "comment_delete_receive", "signature" => $item["signature"], "postId" => $postId, "deleter" => $_SESSION["charme_userid"])));
     // Notifiy followers!
     foreach ($dbReturn3 as $item2) {
         $req21 = new \App\Requests\JSON($item2["follower"], $_SESSION["charme_userid"], $data);
         $arr = $req21->givePostman(2);
     }
     // Notify people seeing the post in their filtered stream
     $cursor4 = $col->streamSubscribers->find(array("postId" => $postId));
     // Send comment to other servers which have registred for it in search_respond
     // These servers will get comment updates for 3? days
     foreach ($cursor4 as $receiver) {
         $req21 = new \App\Requests\JSON("noreply@" . $receiver["server"], $_SESSION["charme_userid"], $data);
         $arr = $req21->givePostman(2);
     }
     //	$col->streamcomments->remove(array("commentId" =>  $item["signature"]["object"]["commentId"], "postowner" => $_SESSION["charme_userid"])); // will be done locally via comment_delete receive
     $col->comments->remove(array("_id" => $commentId, "userId" => $_SESSION["charme_userid"]));
     // Delete comment locally
     $col->comments->remove(array("_id" => $commentId, "postowner" => $_SESSION["charme_userid"]));
     \App\Hydra\Distribute::start();
     // Start server distribution
     break;
     // Comments can either be deleted by post owner or by comment owner, so check if the sender is either one of them
 // Comments can either be deleted by post owner or by comment owner, so check if the sender is either one of them
 case "comment_delete_receive":
     // TODO: Check if sender signature is commentId and also add sender signature to commentId
     $col = \App\DB\Get::Collection();
     $realCommentId = $item["signature"]["object"]["commentId"];