]> git.mxchange.org Git - friendica.git/commitdiff
Make the friendica android client work again (it had problems with the GUID in the...
authorMichael Vogel <icarus@dabo.de>
Sat, 26 Jul 2014 13:01:01 +0000 (15:01 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 26 Jul 2014 13:01:01 +0000 (15:01 +0200)
include/api.php
include/items.php
mod/notify.php
mod/ping.php

index b10c2bf4964d4d6c2191367f9d7808b66d3a4928..7cc72948d184d0e7c96734fdccd8c94868ce1b64 100644 (file)
                        `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
                        FROM `item`, `contact`
                        WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
-                       AND `contact`.`id` = `item`.`contact-id`
+                       AND `contact`.`id` = `item`.`contact-id` AND `item`.`uid` = %d AND `item`.`verb` = '%s'
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        $sql_extra",
+                       intval(api_user()),
+                       dbesc(ACTIVITY_POST),
                        intval($id)
                );
 
index 6f5c88a4789524f5f6b321cf0dce08aaa4a0e019..5b8bb242b38d6b7204ddf7b6fac998082e1a777d 100644 (file)
@@ -1413,6 +1413,41 @@ function get_item_guid($id) {
                return("");
 }
 
+function get_item_id($guid, $uid = 0) {
+
+       $nick = "";
+       $id = 0;
+
+       if ($uid == 0)
+               $uid == local_user();
+
+       // Does the given user have this item?
+       if ($uid) {
+               $r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
+                       WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+                               AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid));
+               if (count($r)) {
+                       $id = $r[0]["id"];
+                       $nick = $r[0]["nickname"];
+               }
+       }
+
+       // Or is it anywhere on the server?
+       if ($nick == "") {
+               $r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid`
+                       WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+                               AND `item`.`allow_cid` = ''  AND `item`.`allow_gid` = ''
+                               AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
+                               AND `item`.`private` = 0 AND `item`.`wall` = 1
+                               AND `item`.`guid` = '%s'", dbesc($guid));
+               if (count($r)) {
+                       $id = $r[0]["id"];
+                       $nick = $r[0]["nickname"];
+               }
+       }
+       return(array("nick" => $nick, "id" => $id));
+}
+
 // return - test
 function get_item_contact($item,$contacts) {
        if(! count($contacts) || (! is_array($item)))
index 256bb77932bfb9ea304de9a3be94b2998281b2cb..f9c5a09b277deeae503998f895ce3650100dd03d 100644 (file)
@@ -17,6 +17,20 @@ function notify_init(&$a) {
                                dbesc($r[0]['otype']),
                                intval(local_user())
                        );
+
+                       // Friendica-Client
+                       $friendicamobile = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)");
+
+                       // The friendica client has problems with the GUID. this is some workaround
+                       if ($friendicamobile) {
+                               require_once("include/items.php");
+                               $urldata = parse_url($r[0]['link']);
+                               $guid = basename($urldata["path"]);
+                               $itemdata = get_item_id($guid, local_user());
+                               if ($itemdata["id"] != 0)
+                                       $r[0]['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
+                       }
+
                        goaway($r[0]['link']);
                }
 
index 07884f453088b045b8e15bbf6a1921dcad5d6a3d..21154f9ffeb6805f34d65e771e3cc2e32cd14bb4 100644 (file)
@@ -59,11 +59,11 @@ function ping_init(&$a) {
                $home = 0;
                $network = 0;
 
-               $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, 
-                               `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, 
-                               `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
+               $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
+                               `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
+                               `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
                                FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
-                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND 
+                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
                                 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `pitem`.`parent` != 0
                                ORDER BY `item`.`created` DESC",
                        intval(local_user())
@@ -109,14 +109,14 @@ function ping_init(&$a) {
                        }
                }
 
-               $intros1 = q("SELECT  `intro`.`id`, `intro`.`datetime`, 
-                       `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` 
+               $intros1 = q("SELECT  `intro`.`id`, `intro`.`datetime`,
+                       `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
                        FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
                        WHERE `intro`.`uid` = %d  AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
                        intval(local_user())
                );
-               $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`, 
-                       `contact`.`name`, `contact`.`url`, `contact`.`photo` 
+               $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
+                       `contact`.`name`, `contact`.`url`, `contact`.`photo`
                        FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
                        WHERE `intro`.`uid` = %d  AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
                        intval(local_user())