Make the friendica android client work again (it had problems with the GUID in the notifications)
This commit is contained in:
parent
10090a6070
commit
25237c0929
|
@ -1127,9 +1127,11 @@
|
||||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||||
FROM `item`, `contact`
|
FROM `item`, `contact`
|
||||||
WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
|
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
|
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||||
$sql_extra",
|
$sql_extra",
|
||||||
|
intval(api_user()),
|
||||||
|
dbesc(ACTIVITY_POST),
|
||||||
intval($id)
|
intval($id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1413,6 +1413,41 @@ function get_item_guid($id) {
|
||||||
return("");
|
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
|
// return - test
|
||||||
function get_item_contact($item,$contacts) {
|
function get_item_contact($item,$contacts) {
|
||||||
if(! count($contacts) || (! is_array($item)))
|
if(! count($contacts) || (! is_array($item)))
|
||||||
|
|
|
@ -17,6 +17,20 @@ function notify_init(&$a) {
|
||||||
dbesc($r[0]['otype']),
|
dbesc($r[0]['otype']),
|
||||||
intval(local_user())
|
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']);
|
goaway($r[0]['link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user