]> git.mxchange.org Git - friendica-addons.git/blobdiff - appnet/appnet.php
Merge pull request #264 from tugelbend/master
[friendica-addons.git] / appnet / appnet.php
index c327bd7d59b997441c7b2da536c6128fae12b2db..171461de184bd7e02dc5243132b9392cf181cc4a 100644 (file)
@@ -690,13 +690,19 @@ function appnet_fetchstream($a, $uid) {
        }
        catch (AppDotNetException $e) {
                logger("appnet_fetchstream: Error fetching stream for user ".$uid." ".appnet_error($e->getMessage()));
+               return;
        }
 
+       if (!is_array($stream))
+               $stream = array();
+
        $stream = array_reverse($stream);
        foreach ($stream AS $post) {
                $postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, true);
 
                $item = item_store($postarray);
+               $postarray["id"] = $item;
+
                logger('appnet_fetchstream: User '.$uid.' posted stream item '.$item);
 
                $lastid = $post["id"];
@@ -744,8 +750,12 @@ function appnet_fetchstream($a, $uid) {
        }
        catch (AppDotNetException $e) {
                logger("appnet_fetchstream: Error fetching mentions for user ".$uid." ".appnet_error($e->getMessage()));
+               return;
        }
 
+       if (!is_array($mentions))
+               $mentions = array();
+
        $mentions = array_reverse($mentions);
        foreach ($mentions AS $post) {
                $postarray = appnet_createpost($a, $uid, $post, $me, $user, $ownid, false);
@@ -755,6 +765,8 @@ function appnet_fetchstream($a, $uid) {
                        $parent_id = $postarray['parent'];
                } elseif (isset($postarray["body"])) {
                        $item = item_store($postarray);
+                       $postarray["id"] = $item;
+
                        $parent_id = 0;
                        logger('appnet_fetchstream: User '.$uid.' posted mention item '.$item);
                } else {
@@ -888,6 +900,8 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th
                                foreach ($thread AS $tpost) {
                                        $threadpost = appnet_createpost($a, $uid, $tpost, $me, $user, $ownid, false, false);
                                        $item = item_store($threadpost);
+                                       $threadpost["id"] = $item;
+
                                        logger("appnet_createpost: stored post ".$post["id"]." thread ".$post["thread_id"]." in item ".$item, LOGGER_DEBUG);
                                }
                        //}