From c81df2c005f8b93016fa2fd2f3532a6a0260f2e5 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 31 Aug 2014 23:52:25 +0200 Subject: [PATCH 1/6] Remote-self is now working immediately --- include/items.php | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/include/items.php b/include/items.php index d929278e23..73b0af7d2d 100644 --- a/include/items.php +++ b/include/items.php @@ -983,7 +983,7 @@ function encode_rel_links($links) { -function item_store($arr,$force_parent = false) { +function item_store($arr,$force_parent = false, $notify = false) { // If a Diaspora signature structure was passed in, pull it out of the // item array and set it aside for later storage. @@ -1144,6 +1144,7 @@ function item_store($arr,$force_parent = false) { $allow_gid = $arr['allow_gid']; $deny_cid = $arr['deny_cid']; $deny_gid = $arr['deny_gid']; + $notify_type = 'wall-new'; } else { @@ -1180,6 +1181,7 @@ function item_store($arr,$force_parent = false) { $deny_cid = $r[0]['deny_cid']; $deny_gid = $r[0]['deny_gid']; $arr['wall'] = $r[0]['wall']; + $notify_type = 'comment-new'; // if the parent is private, force privacy for the entire conversation // This differs from the above settings as it subtly allows comments from @@ -1417,6 +1419,9 @@ function item_store($arr,$force_parent = false) { create_tags_from_item($current_post); create_files_from_item($current_post); + if ($notify) + proc_run('php', "include/notifier.php", $notify_type, $current_post); + return $current_post; } @@ -2532,16 +2537,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if($contact['network'] === NETWORK_FEED) $datarray['private'] = 2; - // This is my contact on another system, but it's really me. - // Turn this into a wall post. - - if($contact['remote_self']) { - $datarray['wall'] = 1; - if($contact['network'] === NETWORK_FEED) { - $datarray['private'] = 0; - } - } - $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; @@ -2557,6 +2552,24 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['owner-avatar'] = $contact['thumb']; } + // This is my contact on another system, but it's really me. + // Turn this into a wall post. + + if($contact['remote_self']) { + $datarray['wall'] = 1; + + // Test + $datarray['author-name'] = $datarray['owner-name']; + $datarray['author-link'] = $datarray['owner-link']; + $datarray['author-avatar'] = $datarray['owner-avatar']; + + $notify = true; + if($contact['network'] === NETWORK_FEED) { + $datarray['private'] = 0; + } + } else + $notify = false; + // We've allowed "followers" to reach this point so we can decide if they are // posting an @-tag delivery, which followers are allowed to do for certain // page types. Now that we've parsed the post, let's check if it is legit. Otherwise ignore it. @@ -2565,7 +2578,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) continue; - $r = item_store($datarray); + $r = item_store($datarray, false, $notify); continue; } @@ -3636,8 +3649,12 @@ function local_delivery($importer,$data) { // This is my contact on another system, but it's really me. // Turn this into a wall post. - if($importer['remote_self']) + if($importer['remote_self']) { $datarray['wall'] = 1; + $notify = true; + } else + $notify = false; + $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['importer_uid']; @@ -3658,7 +3675,7 @@ function local_delivery($importer,$data) { if(($importer['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['importer_uid'],$datarray))) continue; - $posted_id = item_store($datarray); + $posted_id = item_store($datarray, false, $notify); if(stristr($datarray['verb'],ACTIVITY_POKE)) { $verb = urldecode(substr($datarray['verb'],strpos($datarray['verb'],'#')+1)); From 522b9edffe15ef76b471cefda6d029e3aafa1bfe Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 09:59:58 +0200 Subject: [PATCH 2/6] remote-self: Seting the author name to the owner name --- include/items.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/include/items.php b/include/items.php index 73b0af7d2d..c3deed35df 100644 --- a/include/items.php +++ b/include/items.php @@ -2552,6 +2552,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['owner-avatar'] = $contact['thumb']; } + // We've allowed "followers" to reach this point so we can decide if they are + // posting an @-tag delivery, which followers are allowed to do for certain + // page types. Now that we've parsed the post, let's check if it is legit. Otherwise ignore it. + + if(($contact['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['uid'],$datarray))) + continue; + // This is my contact on another system, but it's really me. // Turn this into a wall post. @@ -2570,14 +2577,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } else $notify = false; - // We've allowed "followers" to reach this point so we can decide if they are - // posting an @-tag delivery, which followers are allowed to do for certain - // page types. Now that we've parsed the post, let's check if it is legit. Otherwise ignore it. - - if(($contact['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['uid'],$datarray))) - continue; - - $r = item_store($datarray, false, $notify); continue; @@ -3646,16 +3645,6 @@ function local_delivery($importer,$data) { continue; } - // This is my contact on another system, but it's really me. - // Turn this into a wall post. - - if($importer['remote_self']) { - $datarray['wall'] = 1; - $notify = true; - } else - $notify = false; - - $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; @@ -3675,6 +3664,21 @@ function local_delivery($importer,$data) { if(($importer['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['importer_uid'],$datarray))) continue; + // This is my contact on another system, but it's really me. + // Turn this into a wall post. + + if($importer['remote_self']) { + $datarray['wall'] = 1; + + // Test + $datarray['author-name'] = $datarray['owner-name']; + $datarray['author-link'] = $datarray['owner-link']; + $datarray['author-avatar'] = $datarray['owner-avatar']; + + $notify = true; + } else + $notify = false; + $posted_id = item_store($datarray, false, $notify); if(stristr($datarray['verb'],ACTIVITY_POKE)) { From e35c55dd3bd5de9cd39abaeb2d7d0867f681886d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 14:00:21 +0200 Subject: [PATCH 3/6] Remote-self: It is now possible to chose between two different modes of mirroring. --- include/items.php | 39 ++++++++++++++++++++++++++++++-------- mod/crepair.php | 2 +- view/templates/crepair.tpl | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/items.php b/include/items.php index c3deed35df..0df200aebc 100644 --- a/include/items.php +++ b/include/items.php @@ -2565,10 +2565,21 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if($contact['remote_self']) { $datarray['wall'] = 1; - // Test - $datarray['author-name'] = $datarray['owner-name']; - $datarray['author-link'] = $datarray['owner-link']; - $datarray['author-avatar'] = $datarray['owner-avatar']; + if ($contact['remote_self'] == 2) { + $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid'])); + if (count($r)) { + $datarray['contact-id'] = $r[0]["id"]; + $datarray['network'] = $r[0]["network"]; + + $datarray['owner-name'] = $r[0]["name"]; + $datarray['owner-link'] = $r[0]["url"]; + $datarray['owner-avatar'] = $r[0]["photo"]; + + $datarray['author-name'] = $datarray['owner-name']; + $datarray['author-link'] = $datarray['owner-link']; + $datarray['author-avatar'] = $datarray['owner-avatar']; + } + } $notify = true; if($contact['network'] === NETWORK_FEED) { @@ -3670,10 +3681,22 @@ function local_delivery($importer,$data) { if($importer['remote_self']) { $datarray['wall'] = 1; - // Test - $datarray['author-name'] = $datarray['owner-name']; - $datarray['author-link'] = $datarray['owner-link']; - $datarray['author-avatar'] = $datarray['owner-avatar']; + if ($importer['remote_self'] == 2) { + $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", + intval($importer['importer_uid'])); + if (count($r)) { + $datarray['contact-id'] = $r[0]["id"]; + $datarray['network'] = $r[0]["network"]; + + $datarray['owner-name'] = $r[0]["name"]; + $datarray['owner-link'] = $r[0]["url"]; + $datarray['owner-avatar'] = $r[0]["photo"]; + + $datarray['author-name'] = $datarray['owner-name']; + $datarray['author-link'] = $datarray['owner-link']; + $datarray['author-avatar'] = $datarray['owner-avatar']; + } + } $notify = true; } else diff --git a/mod/crepair.php b/mod/crepair.php index ef5f361305..0706a102d4 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -158,7 +158,7 @@ function crepair_content(&$a) { '$label_photo' => t('New photo from this URL'), '$label_remote_self' => t('Remote Self'), '$allow_remote_self' => get_config('system','allow_users_remote_self'), - '$remote_self' => array('remote_self', t('Mirror postings from this contact'), $contact['remote_self'], t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.')), + '$remote_self' => array('remote_self', t('Mirror postings from this contact'), $contact['remote_self'], t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'), array('0'=>t('No mirroring'), '1'=>t('Mirror as forwarded posting'), '2'=>t('Mirror as my own posting'))), '$contact_name' => $contact['name'], '$contact_nick' => $contact['nick'], '$contact_id' => $contact['id'], diff --git a/view/templates/crepair.tpl b/view/templates/crepair.tpl index d53af5dad7..37e2ef417b 100644 --- a/view/templates/crepair.tpl +++ b/view/templates/crepair.tpl @@ -39,7 +39,7 @@
{{if $allow_remote_self eq 1}}

{{$label_remote_self}}

-{{include file="field_checkbox.tpl" field=$remote_self}} +{{include file="field_select.tpl" field=$remote_self}} {{/if}} From 3e9e682723d2391e4200570ebae155655e4d19d5 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 14:40:29 +0200 Subject: [PATCH 4/6] remote-self: Moved some functionality from other place into the "item_store" function --- include/items.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/items.php b/include/items.php index 0df200aebc..5a238d4fde 100644 --- a/include/items.php +++ b/include/items.php @@ -985,6 +985,13 @@ function encode_rel_links($links) { function item_store($arr,$force_parent = false, $notify = false) { + // If it is a posting where users should get notifications, then define it as wall posting + if ($notify) { + $arr['wall'] = 1; + $arr['type'] = 'wall'; + $arr['network'] = NETWORK_DFRN; + } + // If a Diaspora signature structure was passed in, pull it out of the // item array and set it aside for later storage. @@ -2563,13 +2570,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) // Turn this into a wall post. if($contact['remote_self']) { - $datarray['wall'] = 1; - if ($contact['remote_self'] == 2) { $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['uid'])); if (count($r)) { $datarray['contact-id'] = $r[0]["id"]; - $datarray['network'] = $r[0]["network"]; $datarray['owner-name'] = $r[0]["name"]; $datarray['owner-link'] = $r[0]["url"]; @@ -3679,14 +3683,11 @@ function local_delivery($importer,$data) { // Turn this into a wall post. if($importer['remote_self']) { - $datarray['wall'] = 1; - if ($importer['remote_self'] == 2) { $r = q("SELECT `id`,`url`,`name`,`photo`,`network` FROM `contact` WHERE `uid` = %d AND `self`", intval($importer['importer_uid'])); if (count($r)) { $datarray['contact-id'] = $r[0]["id"]; - $datarray['network'] = $r[0]["network"]; $datarray['owner-name'] = $r[0]["name"]; $datarray['owner-link'] = $r[0]["url"]; From 23c4c39a1ff7a35abc4314eded7ad5d1ab5e5867 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 15:28:31 +0200 Subject: [PATCH 5/6] remote-self: "origin" and "last-child" need to be set as well. --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/items.php b/include/items.php index 5a238d4fde..93bdcb4c39 100644 --- a/include/items.php +++ b/include/items.php @@ -989,6 +989,8 @@ function item_store($arr,$force_parent = false, $notify = false) { if ($notify) { $arr['wall'] = 1; $arr['type'] = 'wall'; + $arr['origin'] = 1; + $arr['last-child'] = 1; $arr['network'] = NETWORK_DFRN; } From 2b182b2dcfd299a28a5ef020ad539eeef226e519 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 16:55:16 +0200 Subject: [PATCH 6/6] After a new friendica contact is added, the user is directed to the contact page of the new contact. (Instead of the remote profile) --- mod/dfrn_request.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 6f6ce61a98..7440c8ab45 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -183,7 +183,9 @@ function dfrn_request_post(&$a) { require_once('include/group.php'); group_add_member(local_user(),'',$r[0]['id'],$g[0]['def_gid']); } - } + $forwardurl = $a->get_baseurl()."/contacts/".$r[0]['id']; + } else + $forwardurl = $a->get_baseurl()."/contacts"; /** * Allow the blocked remote notification to complete @@ -197,7 +199,8 @@ function dfrn_request_post(&$a) { // (ignore reply, nothing we can do it failed) - goaway(zrl($dfrn_url)); + // Old: goaway(zrl($dfrn_url)); + goaway($forwardurl); return; // NOTREACHED }