]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
The "share a post" notification is now sent based upon mentions as well.
[friendica.git] / include / items.php
index 36611dbffa8125c1810330f166cd1a2fc5e628e7..fb357d4db7b41c12e3d9d4c57888db28b780ea21 100644 (file)
@@ -1480,16 +1480,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
        if (!$deleted AND !$dontcache) {
 
                // Store the fresh generated item into the cache
-               $cachefile = get_cachefile(urlencode($arr["guid"])."-".hash("md5", $arr['body']));
-
-               if (($cachefile != '') AND !file_exists($cachefile)) {
-                       $s = prepare_text($arr['body']);
-                       $a = get_app();
-                       $stamp1 = microtime(true);
-                       file_put_contents($cachefile, $s);
-                       $a->save_timestamp($stamp1, "file");
-                       logger('item_store: put item '.$current_post.' into cachefile '.$cachefile);
-               }
+               put_item_in_cache($arr);
 
                $r = q('SELECT * FROM `item` WHERE id = %d', intval($current_post));
                if (count($r) == 1) {
@@ -1499,7 +1490,7 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                }
        }
 
-       create_tags_from_item($current_post, $dontcache);
+       create_tags_from_item($current_post);
        create_files_from_item($current_post);
 
        // Only check for notifications on start posts
@@ -1512,8 +1503,23 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
                        intval($arr['contact-id']),
                        intval($arr['uid'])
                );
+               $send_notification = count($r);
+
+               if (!$send_notification) {
+                       $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
+                               intval(TERM_OBJ_POST), intval($current_post), intval(TERM_MENTION), intval($arr['uid']));
+
+                       if (count($tags)) {
+                               foreach ($tags AS $tag) {
+                                       $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
+                                               normalise_link($tag["url"]), intval($arr['uid']));
+                                       if (count($r))
+                                               $send_notification = true;
+                               }
+                       }
+               }
 
-               if(count($r)) {
+               if ($send_notification) {
                        logger('item_store: Send notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
                        $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
                                intval($arr['uid']));
@@ -4668,8 +4674,8 @@ function drop_item($id,$interactive = true) {
                                dbesc($item['parent-uri']),
                                intval($item['uid'])
                        );
-                       create_tags_from_item($item['parent-uri'], $item['uid']);
-                       create_files_from_item($item['parent-uri'], $item['uid']);
+                       create_tags_from_itemuri($item['parent-uri'], $item['uid']);
+                       create_files_from_itemuri($item['parent-uri'], $item['uid']);
                        delete_thread_uri($item['parent-uri'], $item['uid']);
                        // ignore the result
                }