]> git.mxchange.org Git - friendica.git/blobdiff - include/notifier.php
upgrading the photo and name update
[friendica.git] / include / notifier.php
index 40fdbcc5f720f543d8dccdf92bddb59dd31b61b1..a703dbee9c46bbb66868144f4947245b27c9eb02 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-       $debugging = false;
+       $debugging = true;
 
        require_once("boot.php");
 
@@ -19,9 +19,6 @@
 
        $a->set_baseurl(get_config('system','url'));
 
-       $baseurl = $argv[1];
-       $a->set_baseurl($argv[1]);
-
        $cmd = $argv[1];
 
        switch($cmd) {
@@ -72,7 +69,9 @@
                        killme();
        }
 
-       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+       $r = q("SELECT `contact`.*, `user`.`nickname` 
+               FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` 
+               WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                intval($uid)
        );
 
 
 
        $atom .= replace_macros($feed_template, array(
-                       '$feed_id' => xmlify($a->get_baseurl()),
-                       '$feed_title' => xmlify($owner['name']),
-                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                               $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$name' => xmlify($owner['name']),
+                       '$feed_id'      => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
+                       '$feed_title'   => xmlify($owner['name']),
+                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
+                       '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
-                       '$photo' => xmlify($owner['photo']),
-                       '$thumb' => xmlify($owner['thumb']),
-                       '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+                       '$photo'        => xmlify($owner['photo']),
+                       '$thumb'        => xmlify($owner['thumb']),
+                       '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
+                       '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
+                       '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME))
        ));
 
        if($cmd == 'mail') {
                $atom .= replace_macros($mail_template, array(
-                       '$name' => xmlify($owner['name']),
+                       '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
-                       '$thumb' => xmlify($owner['thumb']),
-                       '$item_id' => xmlify($item['uri']),
-                       '$subject' => xmlify($item['title']),
-                       '$created' => xmlify(datetime_convert('UTC', 'UTC', 
-                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                       '$content' =>xmlify($item['body']),
-                       '$parent_id' => xmlify($item['parent-uri'])
-
+                       '$thumb'        => xmlify($owner['thumb']),
+                       '$item_id'      => xmlify($item['uri']),
+                       '$subject'      => xmlify($item['title']),
+                       '$created'      => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                       '$content'      => xmlify($item['body']),
+                       '$parent_id'    => xmlify($item['parent-uri'])
                ));
        }
        else {
 
+               require_once('include/items.php');
+
+               $verb = construct_verb($item);
+               $actobj = construct_activity($item);
+
+
                if($followup) {
                        foreach($items as $item) {
                                if($item['id'] == $item_id) {
                                        $atom .= replace_macros($cmnt_template, array(
-                                               '$name' => xmlify($owner['name']),
-                                               '$profile_page' => xmlify($owner['url']),
-                                               '$thumb' => xmlify($owner['thumb']),
-                                               '$item_id' => xmlify($item['uri']),
-                                               '$title' => xmlify($item['title']),
-                                               '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                               '$content' => xmlify($item['body']),
-                                               '$parent_id' => xmlify($item['parent-uri']),
-                                               '$comment_allow' => 0
+                                               '$name'               => xmlify($owner['name']),
+                                               '$profile_page'       => xmlify($owner['url']),
+                                               '$thumb'              => xmlify($owner['thumb']),
+                                               '$owner_name'         => xmlify($item['owner-name']),
+                                               '$owner_profile_page' => xmlify($item['owner-link']),
+                                               '$owner_thumb'        => xmlify($item['owner-avatar']),
+                                               '$item_id'            => xmlify($item['uri']),
+                                               '$title'              => xmlify($item['title']),
+                                               '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                               '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                               '$location'           => xmlify($item['location']),
+                                               '$type'               => 'text',
+                                               '$verb'               => xmlify($verb),
+                                               '$actobj'             => $actobj,
+                                               '$content'            => xmlify($item['body']),
+                                               '$parent_id'          => xmlify($item['parent-uri']),
+                                               '$comment_allow'      => 0
                                        ));
                                }
                        }
                                if($item['deleted']) {
                                        $atom .= replace_macros($tomb_template, array(
                                                '$id' => xmlify($item['uri']),
-                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME))
                                        ));
                                }
                                else {
                                                if($item['contact-id'] == $contact['id']) {
                                                        if($item['parent'] == $item['id']) {
                                                                $atom .= replace_macros($item_template, array(
-                                                                       '$name' => xmlify($contact['name']),
-                                                                       '$profile_page' => xmlify($contact['url']),
-                                                                       '$thumb' => xmlify($contact['thumb']),
-                                                                       '$owner_name' => xmlify($item['owner-name']),
+                                                                       '$name'               => xmlify($contact['name']),
+                                                                       '$profile_page'       => xmlify($contact['url']),
+                                                                       '$thumb'              => xmlify($contact['thumb']),
+                                                                       '$owner_name'         => xmlify($item['owner-name']),
                                                                        '$owner_profile_page' => xmlify($item['owner-link']),
-                                                                       '$owner_thumb' => xmlify($item['owner-avatar']),
-                                                                       '$item_id' => xmlify($item['uri']),
-                                                                       '$title' => xmlify($item['title']),
-                                                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$location' => xmlify($item['location']),
-                                                                       '$content' =>xmlify($item['body']),
-                                                                       '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0)
+                                                                       '$owner_thumb'        => xmlify($item['owner-avatar']),
+                                                                       '$item_id'            => xmlify($item['uri']),
+                                                                       '$title'              => xmlify($item['title']),
+                                                                       '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                                                       '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                                                       '$location'           => xmlify($item['location']),
+                                                                       '$type'               => 'text',
+                                                                       '$verb'               => xmlify($verb),
+                                                                       '$actobj'             => $actobj,
+                                                                       '$content'            => xmlify($item['body']),
+                                                                       '$comment_allow'      => (($item['last-child'] && ($contact['rel']) && ($contact['rel'] != REL_FAN)) ? 1 : 0)
                                                                ));
                                                        }
                                                        else {
                                                                $atom .= replace_macros($cmnt_template, array(
-                                                                       '$name' => xmlify($contact['name']),
-                                                                       '$profile_page' => xmlify($contact['url']),
-                                                                       '$thumb' => xmlify($contact['thumb']),
-                                                                       '$item_id' => xmlify($item['uri']),
-                                                                       '$title' => xmlify($item['title']),
-                                                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$content' =>xmlify($item['body']),
-                                                                       '$parent_id' => xmlify($item['parent-uri']),
+                                                                       '$name'          => xmlify($contact['name']),
+                                                                       '$profile_page'  => xmlify($contact['url']),
+                                                                       '$thumb'         => xmlify($contact['thumb']),
+                                                                       '$item_id'       => xmlify($item['uri']),
+                                                                       '$title'         => xmlify($item['title']),
+                                                                       '$published'     => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                                                       '$updated'       => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                                                       '$content'       => xmlify($item['body']),
+                                                                       '$location'      => xmlify($item['location']),
+                                                                       '$type'          => 'text',
+                                                                       '$verb'          => xmlify($verb),
+                                                                       '$actobj'        => $actobj,
+                                                                       '$parent_id'     => xmlify($item['parent-uri']),
                                                                        '$comment_allow' => (($item['last-child']) ? 1 : 0)
                                                                ));
                                                        }
                if($rr['self'])
                        continue;
 
-               if((! strlen($rr['dfrn-id'])) || ($rr['duplex'] && ! strlen($rr['issued-id'])))
+               if((! strlen($rr['dfrn-id'])) && (! $rr['duplex']))
                        continue;
 
-               $idtosend = (($rr['duplex']) ? $rr['issued-id'] : $rr['dfrn-id']);
+               $idtosend = (($rr['dfrn-id']) ? $rr['dfrn-id'] : $rr['issued-id']);
 
                $url = $rr['notify'] . '?dfrn_id=' . $idtosend;
 
                if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
                        continue;
 
-               $postvars = array();
+               $postvars     = array();
+
                $sent_dfrn_id = hex2bin($res->dfrn_id);
-               $challenge = hex2bin($res->challenge);
+               $challenge    = hex2bin($res->challenge);
+
                $final_dfrn_id = '';
 
-               if($rr['duplex']) {
+               if($rr['duplex'] && strlen($rr['prvkey'])) {
                        openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$rr['prvkey']);
                        openssl_private_decrypt($challenge,$postvars['challenge'],$rr['prvkey']);
                }
                }
 
                $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.'));
-               if(($final_dfrn_id != $rr['dfrn-id']) || (($rr['duplex']) && ($final_dfrn_id != $rr['issued-id']))) {
+               if($final_dfrn_id != $idtosend) {
                        // did not decode properly - cannot trust this site 
                        continue;
                }
 
-               $postvars['dfrn_id'] = (($duplex) ? $rr['issued-id'] : $rr['dfrn-id']);
+               $postvars['dfrn_id'] = $idtosend;
 
-               if($cmd == 'mail') {
-                       $postvars['data'] = $atom;
-               }
-               elseif(((strlen($rr['dfrn-id'])) || (($rr['duplex']) && (strlen($rr['issued-id'])))) 
-                       && (! ($rr['blocked']) || ($rr['readonly']))) {
+               if(($rr['rel']) && ($rr['rel'] != REL_FAN) && (! $rr['blocked']) && (! $rr['readonly'])) {
                        $postvars['data'] = $atom;
                }
                else {