*/
namespace Friendica\Protocol;
-use Defuse\Crypto\Crypto;
-use Defuse\Crypto\Exception\EnvironmentIsBrokenException;
-use Defuse\Crypto\Key;
use Friendica\App;
use Friendica\Content\OEmbed;
+use Friendica\Core\Addon;
use Friendica\Core\Config;
+use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Protocol\OStatus;
-use Friendica\Util\Crypto as FriendicaCrypto;
+use Friendica\Util\Crypto;
use Friendica\Util\XML;
use dba;
$root = self::addHeader($doc, $owner, $author, $alternatelink, true);
/// @TODO This hook can't work anymore
- // call_hooks('atom_feed', $atom);
+ // Addon::callHooks('atom_feed', $atom);
if (!DBM::is_result($items) || $onlyheader) {
$atom = trim($doc->saveXML());
- call_hooks('atom_feed_end', $atom);
+ Addon::callHooks('atom_feed_end', $atom);
return $atom;
}
$atom = trim($doc->saveXML());
- call_hooks('atom_feed_end', $atom);
+ Addon::callHooks('atom_feed_end', $atom);
return $atom;
}
/* get site pubkey. this could be a new installation with no site keys*/
$pubkey = Config::get('system', 'site_pubkey');
if (! $pubkey) {
- $res = FriendicaCrypto::newKeypair(1024);
+ $res = Crypto::newKeypair(1024);
Config::set('system', 'site_prvkey', $res['prvkey']);
Config::set('system', 'site_pubkey', $res['pubkey']);
}
XML::addElement($doc, $entry, "dfrn:diaspora_signature", $sign);
}
- XML::addElement($doc, $entry, "activity:verb", construct_verb($item));
+ XML::addElement($doc, $entry, "activity:verb", self::constructVerb($item));
if ($item['object-type'] != "") {
XML::addElement($doc, $entry, "activity:object-type", $item['object-type']);
switch ($rino_remote_version) {
case 1:
- case 2:
- $rino = 1;
- $rino_remote_version = 1;
- // Deprecated rino version!
$key = openssl_random_pseudo_bytes(16);
$data = self::aesEncrypt($postvars['data'], $key);
break;
- case 3:
- try {
- $KeyObject = Key::createNewRandomKey();
- } catch (EnvironmentIsBrokenException $ex) {
- logger('Cannot safely create a key');
- return -4;
- }
-
- try {
- $data = Crypto::encrypt($postvars['data'], $key);
- } catch (EnvironmentIsBrokenException $ex) {
- logger('Cannot safely perform encryption');
- return -6;
- }
-
- $key = $KeyObject->saveToAsciiSafeString();
- break;
default:
logger("rino: invalid requested version '$rino_remote_version'");
return -8;
$postvars['rino'] = $rino_remote_version;
$postvars['data'] = bin2hex($data);
- //logger('rino: sent key = ' . $key, LOGGER_DEBUG);
-
-
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
logger("updating birthday: ".$birthday." for contact ".$contact["id"]);
- $bdtext = sprintf(t("%s\'s birthday"), $contact["name"]);
- $bdtext2 = sprintf(t("Happy Birthday %s"), " [url=".$contact["url"]."]".$contact["name"]."[/url]");
+ $bdtext = L10n::t("%s\'s birthday", $contact["name"]);
+ $bdtext2 = L10n::t("Happy Birthday %s", " [url=".$contact["url"]."]".$contact["name"]."[/url]");
$r = q(
"INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
* valid community action. Also forum_mode makes it valid for sure.
* If neither, it's not.
*/
-
- /// @TODO Maybe merge these if() blocks into one?
if ($is_a_remote_action && $community && (!$r[0]["forum_mode"]) && (!$r[0]["wall"])) {
$is_a_remote_action = false;
logger("not a community action");
$title = "";
foreach ($links as $link) {
foreach ($link->attributes as $attributes) {
- /// @TODO Rewrite these repeated (same) if () statements to a switch()
- if ($attributes->name == "href") {
- $href = $attributes->textContent;
- }
- if ($attributes->name == "rel") {
- $rel = $attributes->textContent;
- }
- if ($attributes->name == "type") {
- $type = $attributes->textContent;
- }
- if ($attributes->name == "length") {
- $length = $attributes->textContent;
- }
- if ($attributes->name == "title") {
- $title = $attributes->textContent;
+ switch ($attributes->name) {
+ case "href" : $href = $attributes->textContent; break;
+ case "rel" : $rel = $attributes->textContent; break;
+ case "type" : $type = $attributes->textContent; break;
+ case "length": $length = $attributes->textContent; break;
+ case "title" : $title = $attributes->textContent; break;
}
}
if (($rel != "") && ($href != "")) {
if (($item["network"] != $author["network"]) && ($author["network"] != "")) {
$item["network"] = $author["network"];
}
-
- /// @TODO maybe remove this old-lost code then?
- // This code was taken from the old DFRN code
- // When activated, forums don't work.
- // And: Why should we disallow commenting by followers?
- // the behaviour is now similar to the Diaspora part.
- //if ($importer["rel"] == CONTACT_IS_FOLLOWER) {
- // logger("Contact ".$importer["id"]." is only follower. Quitting", LOGGER_DEBUG);
- // return;
- //}
}
if ($entrytype == DFRN_REPLY_RC) {
$ev = bbtoevent($item["body"]);
if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
logger("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG);
- /// @TODO Mixure of "/' ahead ...
- $ev["cid"] = $importer["id"];
- $ev["uid"] = $importer["uid"];
- $ev["uri"] = $item["uri"];
- $ev["edited"] = $item["edited"];
- $ev['private'] = $item['private'];
- $ev["guid"] = $item["guid"];
+ $ev["cid"] = $importer["id"];
+ $ev["uid"] = $importer["uid"];
+ $ev["uri"] = $item["uri"];
+ $ev["edited"] = $item["edited"];
+ $ev["private"] = $item["private"];
+ $ev["guid"] = $item["guid"];
$r = q(
"SELECT `id` FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
return;
}
+
+ /**
+ * @brief Returns the activity verb
+ *
+ * @param array $item Item array
+ *
+ * @return string activity verb
+ */
+ private static function constructVerb(array $item)
+ {
+ if ($item['verb']) {
+ return $item['verb'];
+ }
+ return ACTIVITY_POST;
+ }
}