]> git.mxchange.org Git - friendica.git/commitdiff
email notify now redirected through mod_notify, weirdness in local deliver caused...
authorfriendica <info@friendica.com>
Tue, 21 Feb 2012 03:50:05 +0000 (19:50 -0800)
committerfriendica <info@friendica.com>
Tue, 21 Feb 2012 03:50:05 +0000 (19:50 -0800)
boot.php
database.sql
include/enotify.php
include/items.php
mod/notify.php [new file with mode: 0644]
update.php

index 2c9bb68d19b26b70ebfb35857074835beaca6a26..a988e826dd9985fc04bf941421a1f7eb63bc6fd5 100755 (executable)
--- a/boot.php
+++ b/boot.php
@@ -11,7 +11,7 @@ require_once('include/cache.php');
 define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_VERSION',      '2.3.1258' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    );
-define ( 'DB_UPDATE_VERSION',      1122      );
+define ( 'DB_UPDATE_VERSION',      1123      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
index 32d7cf40b42d1149649f311a5334198d6f62e124..e051cdaac5c611d031dfb4725ce9cf43e1d09d58 100755 (executable)
@@ -741,6 +741,7 @@ CREATE TABLE IF NOT EXISTS `conv` (
 
 CREATE TABLE IF NOT EXISTS `notify` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`hash` CHAR( 64 ) NOT NULL,
 `type` INT( 11 ) NOT NULL ,
 `name` CHAR( 255 ) NOT NULL ,
 `url` CHAR( 255 ) NOT NULL ,
@@ -752,6 +753,7 @@ CREATE TABLE IF NOT EXISTS `notify` (
 `seen` TINYINT( 1 ) NOT NULL DEFAULT '0',
 `verb` CHAR( 255 ) NOT NULL,
 `otype` CHAR( 16 ) NOT NULL,
+INDEX ( `hash` ),
 INDEX ( `type` ),
 INDEX ( `uid` ),
 INDEX ( `seen` ),
index b0967cff1baed59aa530be8e25dc5c655b3b9552..c19cc3a9c867971a6b0da8d84fd89ac32eaf1fca 100755 (executable)
@@ -116,10 +116,23 @@ function notification($params) {
 
        require_once('include/html2bbcode.php');        
 
+       do {
+               $dups = false;
+               $hash = random_string();
+        $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
+                       dbesc($hash));
+               if(count($r))
+                       $dups = true;
+       } while($dups == true);
+
+
+
+
        // create notification entry in DB
 
-       $r = q("insert into notify (name,url,photo,date,msg,uid,link,type,verb,otype)
-               values('%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')",
+       $r = q("insert into notify (hash,name,url,photo,date,msg,uid,link,type,verb,otype)
+               values('%s','%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')",
+               dbesc($hash),
                dbesc($params['source_name']),
                dbesc($params['source_link']),
                dbesc($params['source_photo']),
@@ -132,6 +145,17 @@ function notification($params) {
                dbesc($params['otype'])
        );
 
+       $r = q("select id from notify where hash = '%s' and uid = %d limit 1",
+               dbesc($hash),
+               intval($params['uid'])
+       );
+       if($r)
+               $notify_id = $r[0]['id'];
+       else
+               return;
+
+       $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
+
        // send email notification if notification preferences permit
 
        require_once('bbcode.php');
index f87a92334c1776f22aa67f92853406e494c2be43..5beccfbe7b29e21df4f875d7f4024a62dc433d3d 100755 (executable)
@@ -2040,7 +2040,6 @@ function local_delivery($importer,$data) {
                }
 
                if($is_reply) {
-
                        $community = false;
 
                        if($importer['page-flags'] == PAGE_COMMUNITY) {
@@ -2054,7 +2053,9 @@ function local_delivery($importer,$data) {
                        // was the top-level post for this reply written by somebody on this site? 
                        // Specifically, the recipient? 
 
-                       $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, 
+                       $is_a_remote_comment = false;
+
+                       $r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`, 
                                `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` 
                                LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` 
                                WHERE `item`.`uri` = '%s' AND `item`.`parent-uri` = '%s'
@@ -2065,9 +2066,13 @@ function local_delivery($importer,$data) {
                                dbesc($parent_uri),
                                intval($importer['importer_uid'])
                        );
+                       if($r && count($r))
+                               $is_a_remote_comment = true;                    
 
-                       if($r && count($r)) {   
+                       if(($community) && (! $r[0]['forum_mode']))
+                               $is_a_remote_comment = false;
 
+                       if($is_a_remote_comment) {
                                logger('local_delivery: received remote comment');
                                $is_like = false;
                                // remote reply to our post. Import and then notify everybody else.
@@ -2188,6 +2193,7 @@ function local_delivery($importer,$data) {
 
                                                }
                                        }
+
                                        return 0;
                                        // NOTREACHED
                                }
diff --git a/mod/notify.php b/mod/notify.php
new file mode 100644 (file)
index 0000000..d1e5022
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+
+function notify_init(&$a) {
+       if(! local_user())
+               return;
+
+       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 id = %d and uid = %d limit 1",
+                               intval($a->argv[2]),
+                               intval(local_user())
+                       );
+                       goaway($r[0]['link']);
+               }
+
+               goaway($a->get_baseurl());
+       }
+}
+
+
+function notify_content(&$a) {
+       if(! local_user())
+               return login();
+}
\ No newline at end of file
index 24138450aa30130c388e7dc858cc1128053e2781..16c1d78488b6e60bd74e7c4b5c57e66508867dba 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1122 );
+define( 'UPDATE_VERSION' , 1123 );
 
 /**
  *
@@ -1065,3 +1065,7 @@ function update_1121() {
 
 }
 
+function update_1122() {
+q("ALTER TABLE `notify` ADD `hash` CHAR( 64 ) NOT NULL AFTER `id` ,
+ADD INDEX ( `hash` ) ");
+}
\ No newline at end of file