Merge pull request #7074 from MrPetovan/task/move-display-to-src

Remove support for defunct Friendica F-Droid app
This commit is contained in:
Philipp 2019-05-02 23:55:54 +02:00 committed by GitHub
commit 97f723e09e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 126 deletions

View file

@ -26,18 +26,6 @@ function notify_init(App $a)
$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']);
}

View file

@ -313,14 +313,7 @@ function ping_init(App $a)
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);

View file

@ -87,7 +87,7 @@ function subthread_content(App $a) {
$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
@ -128,7 +128,7 @@ 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;

View file

@ -40,14 +40,12 @@ function tagger_content(App $a) {
}
$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'];
}
@ -69,12 +67,7 @@ function tagger_content(App $a) {
$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'];
}
$link = XML::escape('<link rel="alternate" type="text/html" href="'. $href . '" />' . "\n");

View file

@ -87,11 +87,6 @@ class App
*/
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)
*/
@ -257,8 +252,6 @@ class App
$this->profiler = $profiler;
$this->logger = $logger;
$this->checkFriendicaApp();
$this->profiler->reset();
$this->reload();
@ -601,28 +594,6 @@ class App
$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
*

View file

@ -2508,62 +2508,6 @@ class Item extends BaseObject
}, $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
*

View file

@ -359,7 +359,7 @@ class DFRN
$ret = Item::select(Item::DELIVER_FIELDLIST, $condition);
$items = Item::inArray($ret);
if (!DBA::isResult($items)) {
exit();
return '';
}
$item = $items[0];
@ -367,7 +367,7 @@ class DFRN
if ($item['uid'] != 0) {
$owner = User::getOwnerDataById($item['uid']);
if (!$owner) {
exit();
return '';
}
} else {
$owner = ['uid' => 0, 'nick' => 'feed-item'];
@ -400,7 +400,7 @@ class DFRN
}
}
} else {
$root = self::entry($doc, $type, $item, $owner, true, 0, true);
self::entry($doc, $type, $item, $owner, true, 0, true);
}
$atom = trim($doc->saveXML());
@ -987,7 +987,7 @@ class DFRN
}
// 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)) {
@ -2212,14 +2212,13 @@ class DFRN
/**
* @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) {
@ -2244,8 +2243,6 @@ class DFRN
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'];
@ -2259,7 +2256,7 @@ class DFRN
"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"],
@ -2754,7 +2751,8 @@ class DFRN
}
if (stristr($item["verb"], ACTIVITY_POKE)) {
self::doPoke($item, $importer, $posted_id);
$item['id'] = $posted_id;
self::doPoke($item, $importer);
}
}
}