/**
* @param string $pattern
* @param string $reason
+ *
* @return int 0 if the block list couldn't be saved, 1 if the pattern was added, 2 if it was updated in place
*/
public function addPattern(string $pattern, string $reason): int
/**
* @param string $pattern
+ *
* @return int 0 if the block list couldn't be saved, 1 if the pattern wasn't found, 2 if it was removed
*/
public function removePattern(string $pattern): int
return $found ? ($this->set($blocklist) ? 2 : 0) : 1;
}
+ /**
+ * @param string $filename
+ *
+ * @return void
+ * @throws Exception
+ * @todo maybe throw more explicit exception
+ */
public function exportToFile(string $filename)
{
$fp = fopen($filename, 'w');
* Extracts a server domain pattern block list from the provided CSV file name. Deduplicates the list based on patterns.
*
* @param string $filename
+ *
* @return array
* @throws Exception
*/
* @param int $cid Contact ID of template
* @return array
*/
- private function addRSSValues(array $arr, int $cid)
+ private function addRSSValues(array $arr, int $cid): array
{
if (empty($cid)) {
return $arr;
* Wrapper around exit() for JSON only responses
*
* @param array $data
+ *
+ * @return void
*/
public function exitWithJson(array $data)
{
/**
* @param array $profile_row array containing data from db table 'profile'
* @param ProfileFields $profileFields
+ *
* @return array
* @throws HTTPException\InternalServerErrorException
*/
- private static function formatProfile($profile_row, ProfileFields $profileFields)
+ private static function formatProfile($profile_row, ProfileFields $profileFields): array
{
$custom_fields = [];
foreach ($profileFields as $profileField) {
* @throws HTTPException\NotFoundException
* @throws \ImagickException
*/
- protected static function list(array $ids, int $total_count, int $uid, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $skip_status = false, bool $include_user_entities = true)
+ protected static function list(array $ids, int $total_count, int $uid, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $skip_status = false, bool $include_user_entities = true): array
{
$return = self::ids($ids, $total_count, $cursor, $count, false);
* @return array
* @throws HTTPException\NotFoundException
*/
- protected static function ids(array $ids, int $total_count, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $stringify_ids = false)
+ protected static function ids(array $ids, int $total_count, int $cursor = -1, int $count = self::DEFAULT_COUNT, bool $stringify_ids = false): array
{
$next_cursor = 0;
$previous_cursor = 0;
* @param array $request
* @param int $uid
* @param array $condition
+ *
+ * @return void
*/
protected function getMessages(array $request, int $uid, array $condition)
{
}
if ($mode == Response::TYPE_XML) {
- self::printXML($alias, DI::baseUrl()->get(), $user, $owner, $avatar);
+ self::printXML($alias, $user, $owner, $avatar);
} else {
- self::printJSON($alias, DI::baseUrl()->get(), $owner, $avatar);
+ self::printJSON($alias, $owner, $avatar);
}
}
System::jsonExit($json, 'application/jrd+json; charset=utf-8');
}
- private static function printJSON($alias, $baseURL, $owner, $avatar)
+ private static function printJSON(string $alias, array $owner, array $avatar)
{
+ $baseURL = DI::baseUrl()->get();
$salmon_key = Salmon::salmonKey($owner['spubkey']);
$json = [
System::jsonExit($json, 'application/jrd+json; charset=utf-8');
}
- private static function printXML($alias, $baseURL, $user, $owner, $avatar)
+ private static function printXML(string $alias, array $user, array $owner, array $avatar)
{
+ $baseURL = DI::baseUrl()->get();
$salmon_key = Salmon::salmonKey($owner['spubkey']);
$tpl = Renderer::getMarkupTemplate('xrd_person.tpl');
* Returns only the most recent notifications for the same conversation or contact
*
* @param int $uid
+ *
* @return Collection\Notifications
* @throws Exception
*/
* Returns only the most recent notifications for the same conversation or contact
*
* @param int $uid
+ *
* @return Collection\Notifications
* @throws Exception
*/
* @param int|null $min_id Retrieve models with an id no fewer than this, as close to it as possible
* @param int|null $max_id Retrieve models with an id no greater than this, as close to it as possible
* @param int $limit
+ *
* @return BaseCollection
* @throws Exception
* @see _selectByBoundaries
/**
* @param array $condition
* @param array $params
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
/**
* @param int $id
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
*/
/**
* @param Entity\Notify $Notify
+ *
* @return Entity\Notify
* @throws HTTPException\NotFoundException
* @throws HTTPException\InternalServerErrorException
case Model\Notification\Type::SYSTEM:
switch($params['event']) {
- case "SYSTEM_REGISTER_REQUEST":
+ case 'SYSTEM_REGISTER_REQUEST':
$itemlink = $params['link'];
$subject = $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('registration request');
$tsitelink = sprintf($sitelink, $params['link']);
$hsitelink = sprintf($sitelink, '<a href="'.$params['link'].'">'.$sitename.'</a><br><br>');
break;
- case "SYSTEM_DB_UPDATE_FAIL":
+
+ case 'SYSTEM_DB_UPDATE_FAIL': // @TODO Unused (only here)
break;
}
break;
return $this->storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $body, $itemlink, $show_in_notification_page);
}
- private function storeAndSend($params, $sitelink, $tsitelink, $hsitelink, $title, $subject, $preamble, $epreamble, $body, $itemlink, $show_in_notification_page)
+ private function storeAndSend(array $params, string $sitelink, string $tsitelink, string $hsitelink, string $title, string $subject, string $preamble, string $epreamble, string $body, string $itemlink, bool $show_in_notification_page): bool
{
$item_id = $params['item']['id'] ?? 0;
$uri_id = $params['item']['uri-id'] ?? null;
return false;
}
- public function createFromNotification(Entity\Notification $Notification)
+ public function createFromNotification(Entity\Notification $Notification): bool
{
$this->logger->info('Start', ['uid' => $Notification->uid, 'id' => $Notification->id, 'type' => $Notification->type]);
return false;
}
- $children = $basedom->children('http://salmon-protocol.org/ns/magic-env');
+ $children = $basedom->children(ActivityNamespace::SALMON_ME);
if (sizeof($children) == 0) {
Logger::notice('XML has no children');
]
];
- $namespaces = ['me' => 'http://salmon-protocol.org/ns/magic-env'];
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
return XML::fromArray($xmldata, $xml, false, $namespaces);
}
$signature3 = Strings::base64UrlEncode(Crypto::rsaSign($data, $owner['sprvkey']));
// At first try the non compliant method that works for GNU Social
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature,
- "@attributes2" => ["key_id" => $keyhash]]];
-
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature,
+ '@attributes2' => ['key_id' => $keyhash],
+ ]
+ ];
+
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
Logger::notice('GNU Social salmon failed. Falling back to compliant mode');
// Now try the compliant mode that normally isn't used for GNU Social
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature2,
- "@attributes2" => ["key_id" => $keyhash]]];
-
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature2,
+ '@attributes2' => ['key_id' => $keyhash]
+ ]
+ ];
+
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);
Logger::notice('compliant salmon failed. Falling back to old status.net');
// Last try. This will most likely fail as well.
- $xmldata = ["me:env" => ["me:data" => $data,
- "@attributes" => ["type" => $data_type],
- "me:encoding" => $encoding,
- "me:alg" => $algorithm,
- "me:sig" => $signature3,
- "@attributes2" => ["key_id" => $keyhash]]];
-
- $namespaces = ["me" => "http://salmon-protocol.org/ns/magic-env"];
+ $xmldata = [
+ 'me:env' => [
+ 'me:data' => $data,
+ '@attributes' => ['type' => $data_type],
+ 'me:encoding' => $encoding,
+ 'me:alg' => $algorithm,
+ 'me:sig' => $signature3,
+ '@attributes2' => ['key_id' => $keyhash],
+ ]
+ ];
+
+ $namespaces = ['me' => ActivityNamespace::SALMON_ME];
$salmon = XML::fromArray($xmldata, $xml, false, $namespaces);