]> git.mxchange.org Git - friendica.git/commitdiff
d* pm
authorfriendica <info@friendica.com>
Tue, 6 Dec 2011 08:16:13 +0000 (00:16 -0800)
committerfriendica <info@friendica.com>
Tue, 6 Dec 2011 08:16:13 +0000 (00:16 -0800)
boot.php
database.sql
include/acl_selectors.php
include/diaspora.php
include/message.php
include/notifier.php
update.php

index 875d4a69b40ab5c48e2f07f955f6f586469ecbca..a5904ef01e9f46a8725d97a9fd2622b7bd3c434d 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -11,7 +11,7 @@ require_once('include/cache.php');
 define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_VERSION',      '2.3.1186' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.22'    );
-define ( 'DB_UPDATE_VERSION',      1109      );
+define ( 'DB_UPDATE_VERSION',      1110      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
@@ -21,8 +21,9 @@ define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
  *
  * Image storage quality. Lower numbers save space at cost of image detail.
  * For ease of upgrade, please do not change here. Change jpeg quality with 
- * set_config('system','jpeg_quality',n) in .htconfig.php
- * where n is netween 1 and 100, and with very poor results below about 50 
+ * $a->config['system']['jpeg_quality'] = n; 
+ * in .htconfig.php, where n is netween 1 and 100, and with very poor results 
+ * below about 50 
  *
  */
 
index 18fe5f8c332580bfeafa638104d215911c540eb3..cdbc8a93b4278712f0f7a419384e4dbfaf03f9da 100644 (file)
@@ -714,5 +714,11 @@ CREATE TABLE IF NOT EXISTS `conv` (
   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
   `guid` CHAR( 64 ) NOT NULL ,
   `recips` MEDIUMTEXT NOT NULL ,
-  `uid` INT NOT NULL
+  `uid` INT NOT NULL,
+  `creator` CHAR( 255 ) NOT NULL ,
+  `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `subject` MEDIUMTEXT NOT NULL,
+  INDEX ( `created` ),
+  INDEX ( `updated` )
 ) ENGINE = MyISAM DEFAULT CHARSET=utf8;
index 66fe104eaab2aee3acc1901564cb2064ea6b756f..d8f530daf61366f9bf59fd64fe3fff0d6e56dee2 100644 (file)
@@ -167,7 +167,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
        }
 
        if($privmail) {
-               $sql_extra .= " AND `network` IN ( 'dfrn' ) ";
+               $sql_extra .= " AND `network` IN ( 'dfrn', 'dspr' ) ";
        }
        elseif($privatenet) {   
                $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) ";
index fe853b5df56b402bc3c084d5fb9ba57ebfc2069e..a8fd430246dd362bd204e9502b590ace4286256e 100644 (file)
@@ -1096,9 +1096,13 @@ function diaspora_conversation($importer,$xml,$msg) {
        if(count($c))
                $conversation = $c[0];
        else {
-               $r = q("insert into conv (uid,guid,recips) values(%d, '%s', '%s') ",
+               $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
                        intval($importer['uid']),
                        dbesc($guid),
+                       dbesc($diaspora_handle),
+                       dbesc(datetime_convert('UTC','UTC',$created_at)),
+                       dbesc(datetime_convert()),
+                       dbesc($subject),
                        dbesc($participant_handles)
                );
                if($r)
@@ -1203,6 +1207,10 @@ function diaspora_conversation($importer,$xml,$msg) {
                        dbesc($msg_created_at)
                );                      
 
+               q("updated conv set updated = '%s' where id = %d limit 1",
+                       dbesc(datetime_convert()),
+                       intval($conversation['id'])
+               );              
        }       
 
        return;
@@ -1943,7 +1951,73 @@ function diaspora_send_retraction($item,$owner,$contact,$public_batch = false) {
        return(diaspora_transmit($owner,$contact,$slap,$public_batch));
 }
 
+function diaspora_send_mail($item,$owner,$contact) {
+
+       $a = get_app();
+       $myaddr = $owner['nickname'] . '@' .  substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+       $r = q("select * from conv where id = %d and uid = %d limit 1",
+               intval($item['convid']),
+               intval($item['uid'])
+       );
+
+       if(! count($r)) {
+               logger('diaspora_send_mail: conversation not found.');
+               return;
+       }
+       $cnv = $r[0];
+
+       $parent = null;
+
+       if($item['parent-uri'] != $item['uri']) {
+               $r = q("select * from mail where uri = '%s' and uid = %d limit 1",
+                       dbesc($item['parent-uri']),
+                       intval($item['uid'])
+               );
+               $parent = $r[0];
+       }
 
+       $conv = array(
+               'guid' => xmlify($cnv['guid']),
+               'subject' => xmlify($cnv['subject']),
+               'created_at' => xmlify(datetime_convert('UTC','UTC',$cnv['created'],'Y-m-d H:i:s \U\T\C')),
+               'diaspora_handle' => xmlify($cnv['creator']),
+               'participant_handles' => xmlify($cnv['recips'])
+       );
+
+       $body = bb2diaspora($item['body']);
+       $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
+       $parent_guid = (($item['parent-uri'] == $item['uri']) ? $cnv['guid'] : $parent['guid']);
+       $signed_text =  $item['guid'] . ';' . $parent_guid . ';' . $body .  ';' 
+               . $created . ';' . $myaddr . ';' . $cnv['guid'];
+
+       $sig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
+
+       $msg = array(
+               'guid' => xmlify($item['guid']),
+               'parent_guid' => (($item['parent-uri'] == $item['uri']) ? xmlify($cnv['guid']) : xmlify($parent['guid'])),
+               'parent_author_signature' => (($item['parent-uri'] == $item['uri']) ? xmlify($sig) : null),
+               'author_signature' => xmlify($sig),
+               'text' => xmlify($body),
+               'created_at' => xmlify($created),
+               'diaspora_handle' => xmlify($myaddr),
+               'conversation_guid' => xmlify($cnv['guid'])
+       );
+
+       $conv['messages'] = array($msg);
+
+       $tpl = get_markup_template('diaspora_conversation.tpl');
+       $msg = replace_macros($tpl, array('$conv' => $conv));
+
+       logger('diaspora_conversation: ' . print_r($msg,true));
+
+       $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],false)));
+
+       return(diaspora_transmit($owner,$contact,$slap,false));
+
+
+}
 
 function diaspora_transmit($owner,$contact,$slap,$public_batch) {
 
index baf1bb2d5c6f4c6158130a3d95cd10e1558ec23a..58789d6884a0f9b1ba5866e9e4eab26cb0d2cd4c 100644 (file)
@@ -58,11 +58,16 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
 
                $handles = $recip_handle . ';' . $sender_handle;
 
-               $r = q("insert into conv (uid,guid,recips) values (%d, '%s', '%s') ",
+               $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
                        intval(local_user()),
                        dbesc($conv_guid),
+                       dbesc($sender_handle),
+                       dbesc(datetime_convert()),
+                       dbesc(datetime_convert()),
+                       dbesc($subject),
                        dbesc($handles)
                );
+
                $r = q("select * from conv where guid = '%s' and uid = %d limit 1",
                        dbesc($conv_guid),
                        intval(local_user())
@@ -76,10 +81,11 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
                return -4;
        }
 
-       $r = q("INSERT INTO `mail` ( `uid`, `convid`, `from-name`, `from-photo`, `from-url`, 
+       $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, 
                `contact-id`, `title`, `body`, `seen`, `replied`, `uri`, `parent-uri`, `created`)
-               VALUES ( %d, %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s', '%s', '%s' )",
+               VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s', '%s', '%s' )",
                intval(local_user()),
+               dbesc(get_guid()),
                intval($convid),
                dbesc($me[0]['name']),
                dbesc($me[0]['thumb']),
index 945ba95e7b72bc448ec82908c0f3d9a5050b33a4..2562f09eb05bb53f64187268a54d3ba1c72afe86 100644 (file)
@@ -663,7 +663,15 @@ function notifier_run($argv, $argc){
                                case NETWORK_DIASPORA:
                                        require_once('include/diaspora.php');
 
-                                       if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
+                                       if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')))
+                                               break;
+
+                                       if($mail) {
+                                               diaspora_send_mail($item,$owner,$contact);
+                                               break;
+                                       }
+
+                                       if(! $normal_mode)
                                                break;
 
                                        // special handling for followup to public post
index d94bf82d1752f7fb0d97ec2306874307f8886a7b..ca8874e82a25ff7f890de1b9714f761afe0f401e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1109 );
+define( 'UPDATE_VERSION' , 1110 );
 
 /**
  *
@@ -928,3 +928,12 @@ function update_1108() {
 ADD INDEX ( `hidden` ) ");
 
 }
+
+function update_1109() {
+       q("ALTER TABLE `conv` ADD `creator` CHAR( 255 ) NOT NULL ,
+               ADD `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+               ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
+               ADD `subject` MEDIUMTEXT NOT NULL,
+               ADD INDEX ( `created` ), ADD INDEX ( `updated` ) ");
+}
+