- if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
- $r = q("select * from notify where id = %d and uid = %d limit 1",
- intval($a->argv[2]),
- intval(local_user())
- );
- if(count($r)) {
- q("update notify set seen = 1 where ( link = '%s' or ( parent != 0 and parent = %d and otype = '%s' )) and uid = %d",
- dbesc($r[0]['link']),
- intval($r[0]['parent']),
- dbesc($r[0]['otype']),
- intval(local_user())
- );
- goaway($r[0]['link']);
+ if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
+ $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->is_friendica_app()) {
+ 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"];
+ }
+ }
+
+ goaway($note['link']);