X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdfrn_notify.php;h=f581702d8e23bcce60c3abd5ac327964a7a0c4c2;hb=d2dddd995abef2d0805901b278647bef0ce50f88;hp=cd7523a01c27cb8a891f9a5e972dfa667dedb6f2;hpb=9513f1f1668a33be3fc2b241fe3662e9de42d84b;p=friendica.git diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index cd7523a01c..f581702d8e 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -11,6 +11,7 @@ function dfrn_notify_post(&$a) { $challenge = ((x($_POST,'challenge')) ? notags(trim($_POST['challenge'])) : ''); $data = ((x($_POST,'data')) ? $_POST['data'] : ''); $key = ((x($_POST,'key')) ? $_POST['key'] : ''); + $dissolve = ((x($_POST,'dissolve')) ? intval($_POST['dissolve']) : 0); $direction = (-1); if(strpos($dfrn_id,':') == 1) { @@ -51,6 +52,8 @@ function dfrn_notify_post(&$a) { } + + $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, `contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` @@ -65,17 +68,24 @@ function dfrn_notify_post(&$a) { //NOTREACHED } + // $importer in this case contains the contact record for the remote contact joined with the user record of our user. + $importer = $r[0]; logger('dfrn_notify: received notify from ' . $importer['name'] . ' for ' . $importer['username']); logger('dfrn_notify: data: ' . $data, LOGGER_DATA); - if($importer['readonly']) { - // We aren't receiving stuff from this person. But we will quietly ignore them - // rather than a blatant "go away" message. - logger('dfrn_notify: ignoring'); + if($dissolve == 1) { + + /** + * Relationship is dissolved permanently + */ + + require_once('include/Contact.php'); + contact_remove($importer['id']); + logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']); xml_status(0); - //NOTREACHED + } if(strlen($key)) { @@ -95,6 +105,17 @@ function dfrn_notify_post(&$a) { logger('rino: decrypted data: ' . $data, LOGGER_DATA); } + + + + if($importer['readonly']) { + // We aren't receiving stuff from this person. But we will quietly ignore them + // rather than a blatant "go away" message. + logger('dfrn_notify: ignoring'); + xml_status(0); + //NOTREACHED + } + // Consume notification feed. This may differ from consuming a public feed in several ways // - might contain email // - might contain remote followup to our message @@ -245,6 +266,7 @@ function dfrn_notify_post(&$a) { if($is_reply) { if($feed->get_item_quantity() == 1) { logger('dfrn_notify: received remote comment'); + $is_like = false; // remote reply to our post. Import and then notify everybody else. $datarray = get_atom_elements($feed,$item); $datarray['type'] = 'remote-comment'; @@ -253,35 +275,39 @@ function dfrn_notify_post(&$a) { $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) { + $is_like = true; $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; + $datarray['last-child'] = 0; } $posted_id = item_store($datarray); if($posted_id) { - $r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($posted_id), - intval($importer['importer_uid']) - ); - if(count($r)) { - $r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d", - dbesc(datetime_convert()), - intval($importer['importer_uid']), - intval($r[0]['parent']) + if(! $is_like) { + $r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($posted_id), + intval($importer['importer_uid']) + ); + if(count($r)) { + $r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d", + dbesc(datetime_convert()), + intval($importer['importer_uid']), + intval($r[0]['parent']) + ); + } + $r2 = q("UPDATE `item` SET `last-child` = 1, `changed` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($importer['importer_uid']), + intval($posted_id) ); } - $r2 = q("UPDATE `item` SET `last-child` = 1, `changed` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", - dbesc(datetime_convert()), - intval($importer['importer_uid']), - intval($posted_id) - ); $php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php'); proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &", array(),$foo)); - if(($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) { + if((! $is_like) && ($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) { require_once('bbcode.php'); $from = stripslashes($datarray['author-name']); $tpl = load_view_file('view/cmnt_received_eml.tpl'); @@ -295,10 +321,11 @@ function dfrn_notify_post(&$a) { '$body' => strip_tags(bbcode(stripslashes($datarray['body']))) )); - $res = mail($importer['email'], $from . t(" commented on an item at ") . $a->config['sitename'], - $email_tpl,t("From: Administrator@") . $a->get_hostname() ); + $res = mail($importer['email'], $from . t(' commented on an item at ') . $a->config['sitename'], + $email_tpl, "From: " . t('Administrator') . '@' . $a->get_hostname() ); } } + xml_status(0); // NOTREACHED @@ -357,7 +384,7 @@ function dfrn_notify_post(&$a) { '$username' => $importer['username'], '$email' => $importer['email'], '$from' => $from, - '$display' => $a->get_baseurl() . '/display/' . $r, + '$display' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $r, '$body' => strip_tags(bbcode(stripslashes($datarray['body']))) ));