$note = $nm->getByID($a->argv[2]);
if ($note) {
$nm->setSeen($note);
-
- // The friendica client has problems with the GUID. this is some workaround
- if ($a->isFriendicaApp()) {
- require_once("include/items.php");
- $urldata = parse_url($note['link']);
- $guid = basename($urldata["path"]);
- $itemdata = Item::getIdAndNickByGuid($guid, local_user());
- if ($itemdata["id"] != 0) {
- $note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
- }
- }
-
System::externalRedirect($note['link']);
}
usort($notifs, $sort_function);
if (DBA::isResult($notifs)) {
- // Are the nofications called from the regular process or via the friendica app?
- $regularnotifications = (!empty($_GET['uid']) && !empty($_GET['_']));
-
foreach ($notifs as $notif) {
- if ($a->isFriendicaApp() || !$regularnotifications) {
- $notif['message'] = str_replace("{0}", $notif['name'], $notif['message']);
- }
-
$contact = Contact::getDetailsByURL($notif['url']);
if (isset($contact['micro'])) {
$notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO);
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
- $link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n");
+ $link = XML::escape('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $item['guid'] . '" />' . "\n");
$body = $item['body'];
$obj = <<< EOT
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . System::baseUrl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+ $plink = '[url=' . System::baseUrl() . '/display/' . $item['guid'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['verb'] = $activity;
}
$owner_uid = $item['uid'];
- $owner_nick = '';
$blocktags = 0;
- $r = q("select `nickname`,`blocktags` from user where uid = %d limit 1",
+ $r = q("select `blocktags` from user where uid = %d limit 1",
intval($owner_uid)
);
if (DBA::isResult($r)) {
- $owner_nick = $r[0]['nickname'];
$blocktags = $r[0]['blocktags'];
}
$xterm = XML::escape($term);
$post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
$targettype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
-
- if ($owner_nick) {
- $href = System::baseUrl() . '/display/' . $owner_nick . '/' . $item['id'];
- } else {
- $href = System::baseUrl() . '/display/' . $item['guid'];
- }
+ $href = System::baseUrl() . '/display/' . $item['guid'];
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");
*/
private $baseURL;
- /**
- * @var bool true, if the call is from the Friendica APP, otherwise false
- */
- private $isFriendicaApp;
-
/**
* @var bool true, if the call is from an backend node (f.e. worker)
*/
$this->profiler = $profiler;
$this->logger = $logger;
- $this->checkFriendicaApp();
-
$this->profiler->reset();
$this->reload();
$this->getBaseURL();
}
- /**
- * Checks, if the call is from the Friendica App
- *
- * Reason:
- * The friendica client has problems with the GUID in the notify. this is some workaround
- */
- private function checkFriendicaApp()
- {
- // Friendica-Client
- $this->isFriendicaApp = isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] == 'Apache-HttpClient/UNAVAILABLE (java 1.4)';
- }
-
- /**
- * Is the call via the Friendica app? (not a "normale" call)
- *
- * @return bool true if it's from the Friendica app
- */
- public function isFriendicaApp()
- {
- return $this->isFriendicaApp;
- }
-
/**
* @brief Checks if the site is called via a backend process
*
}, $item["body"]);
}
- public static function getGuidById($id)
- {
- $item = self::selectFirst(['guid'], ['id' => $id]);
- if (DBA::isResult($item)) {
- return $item['guid'];
- } else {
- return '';
- }
- }
-
- /**
- * This function is only used for the old Friendica app on Android that doesn't like paths with guid
- *
- * @param string $guid item guid
- * @param int $uid user id
- * @return array with id and nick of the item with the given guid
- * @throws \Exception
- */
- public static function getIdAndNickByGuid($guid, $uid = 0)
- {
- $nick = "";
- $id = 0;
-
- if ($uid == 0) {
- $uid = local_user();
- }
-
- // Does the given user have this item?
- if ($uid) {
- $item = self::selectFirst(['id'], ['guid' => $guid, 'uid' => $uid]);
- if (DBA::isResult($item)) {
- $user = DBA::selectFirst('user', ['nickname'], ['uid' => $uid]);
- if (!DBA::isResult($user)) {
- return;
- }
- $id = $item['id'];
- $nick = $user['nickname'];
- }
- }
-
- // Or is it anywhere on the server?
- if ($nick == "") {
- $condition = ["`guid` = ? AND `uid` != 0", $guid];
- $item = self::selectFirst(['id', 'uid'], $condition);
- if (DBA::isResult($item)) {
- $user = DBA::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
- if (!DBA::isResult($user)) {
- return;
- }
- $id = $item['id'];
- $nick = $user['nickname'];
- }
- }
- return ["nick" => $nick, "id" => $id];
- }
-
/**
* look for mention tags and setup a second delivery chain for forum/community posts if appropriate
*
$ret = Item::select(Item::DELIVER_FIELDLIST, $condition);
$items = Item::inArray($ret);
if (!DBA::isResult($items)) {
- exit();
+ return '';
}
$item = $items[0];
if ($item['uid'] != 0) {
$owner = User::getOwnerDataById($item['uid']);
if (!$owner) {
- exit();
+ return '';
}
} else {
$owner = ['uid' => 0, 'nick' => 'feed-item'];
}
}
} else {
- $root = self::entry($doc, $type, $item, $owner, true, 0, true);
+ self::entry($doc, $type, $item, $owner, true, 0, true);
}
$atom = trim($doc->saveXML());
}
// Add conversation data. This is used for OStatus
- $conversation_href = System::baseUrl()."/display/".$owner["nick"]."/".$item["parent"];
+ $conversation_href = System::baseUrl()."/display/".$item["parent-guid"];
$conversation_uri = $conversation_href;
if (isset($parent_item)) {
/**
* @brief Send a "poke"
*
- * @param array $item the new item record
+ * @param array $item The new item record
* @param array $importer Record of the importer user mixed with contact of the content
- * @param int $posted_id The record number of item record that was just posted
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo set proper type-hints (array?)
*/
- private static function doPoke($item, $importer, $posted_id)
+ private static function doPoke(array $item, array $importer)
{
$verb = urldecode(substr($item["verb"], strpos($item["verb"], "#")+1));
if (!$verb) {
if ($Blink && Strings::compareLink($Blink, System::baseUrl() . "/profile/" . $importer["nickname"])) {
$author = DBA::selectFirst('contact', ['name', 'thumb', 'url'], ['id' => $item['author-id']]);
- $item['id'] = $posted_id;
-
$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => $importer["importer_uid"]]);
$item["parent"] = $parent['id'];
"to_email" => $importer["email"],
"uid" => $importer["importer_uid"],
"item" => $item,
- "link" => System::baseUrl()."/display/".urlencode(Item::getGuidById($posted_id)),
+ "link" => System::baseUrl()."/display/".urlencode($item['guid']),
"source_name" => $author["name"],
"source_link" => $author["url"],
"source_photo" => $author["thumb"],
}
if (stristr($item["verb"], ACTIVITY_POKE)) {
- self::doPoke($item, $importer, $posted_id);
+ $item['id'] = $posted_id;
+ self::doPoke($item, $importer);
}
}
}