Exemple #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"]);
    }
}
Exemple #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;
     }
 }
Exemple #3
0
         // 	if ($messageData["usernames"][$i]["userId"] == $_SESSION["charme_userid"])
         // 			$messageData["usernames"][$i]["name"] = $sendername;
         //	 }
         foreach ($messageData["usernames"] as $userTuple) {
             $receiverId = $userTuple["userId"];
             $keyobj = array();
             // Get the message key
             foreach ($item["messageKeys"] as $value) {
                 if ($value["userId"] == $receiverId) {
                     $keyobj = $value;
                 }
             }
             $content = array(array("id" => "message_receive", "messageData" => $item["messageData"], "key" => $keyobj));
             $data = array("requests" => $content);
             $serverRequest = new \App\Requests\JSON($receiverId, $_SESSION["charme_userid"], $data);
             $serverRequest->send();
         }
     }
     $returnArray[$action] = array("STATUS" => "OK", "messageId" => $conversationId);
     break;
 case "message_notify_newpeople":
     break;
 case "user_login":
     // Get certificate
     $sessionIdOfUser = "";
     global $CHARME_SETTINGS;
     global $CHARME_VERSION;
     $col = \App\DB\Get::Collection();
     $p1 = $item["p"];
     if (!isset($CHARME_SETTINGS["passwordSalt"])) {
         die("CHARME_SETTINGS NOT INCLUDED");