Issue-3412 related: Don't send connection posts anymore

This commit is contained in:
Michael 2018-05-19 19:34:51 +00:00
parent 139f7cdc41
commit c70ebadd7d
12 changed files with 0 additions and 298 deletions

View file

@ -83,14 +83,12 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$duplex = $handsfree['duplex']; $duplex = $handsfree['duplex'];
$cid = 0; $cid = 0;
$hidden = intval(defaults($handsfree, 'hidden' , 0)); $hidden = intval(defaults($handsfree, 'hidden' , 0));
$activity = intval(defaults($handsfree, 'activity', 0));
} else { } else {
$dfrn_id = notags(trim(defaults($_POST, 'dfrn_id' , ''))); $dfrn_id = notags(trim(defaults($_POST, 'dfrn_id' , '')));
$intro_id = intval(defaults($_POST, 'intro_id' , 0)); $intro_id = intval(defaults($_POST, 'intro_id' , 0));
$duplex = intval(defaults($_POST, 'duplex' , 0)); $duplex = intval(defaults($_POST, 'duplex' , 0));
$cid = intval(defaults($_POST, 'contact_id', 0)); $cid = intval(defaults($_POST, 'contact_id', 0));
$hidden = intval(defaults($_POST, 'hidden' , 0)); $hidden = intval(defaults($_POST, 'hidden' , 0));
$activity = intval(defaults($_POST, 'activity' , 0));
} }
/* /*
@ -401,50 +399,6 @@ function dfrn_confirm_post(App $a, $handsfree = null)
$ret = Diaspora::sendShare($user, $contact); $ret = Diaspora::sendShare($user, $contact);
logger('share returns: ' . $ret); logger('share returns: ' . $ret);
} }
// Send a new friend post if we are allowed to...
$profile = dba::selectFirst('profile', ['hide-friends'], ['is-default' => true, 'uid' => $uid]);
if (x($profile, 'hide-friends') === 0 && $activity && !$hidden) {
$self = dba::selectFirst('contact', [], ['self' => true, 'uid' => $uid]);
if (DBM::is_result($self)) {
$arr = [];
$arr['guid'] = get_guid(32);
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $uid);
$arr['uid'] = $uid;
$arr['contact-id'] = $self['id'];
$arr['wall'] = 1;
$arr['type'] = 'wall';
$arr['gravity'] = 0;
$arr['origin'] = 1;
$arr['author-name'] = $arr['owner-name'] = $self['name'];
$arr['author-link'] = $arr['owner-link'] = $self['url'];
$arr['author-avatar'] = $arr['owner-avatar'] = $self['thumb'];
$A = '[url=' . $self['url'] . ']' . $self['name'] . '[/url]';
$B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]';
$arr['verb'] = ACTIVITY_FRIEND;
$arr['object-type'] = ACTIVITY_OBJ_PERSON;
$arr['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B) . "\n\n\n" . $BPhoto;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $contact['name'] . '</title>'
. '<id>' . $contact['url'] . '/' . $contact['name'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $contact['url'] . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $contact['thumb'] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n";
$arr['allow_cid'] = $user['allow_cid'];
$arr['allow_gid'] = $user['allow_gid'];
$arr['deny_cid'] = $user['deny_cid'];
$arr['deny_gid'] = $user['deny_gid'];
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
}
}
} }
Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']); Group::addMember(User::getDefaultGroup($uid, $contact["network"]), $contact['id']);
@ -665,49 +619,6 @@ function dfrn_confirm_post(App $a, $handsfree = null)
} }
} }
// Send a new friend post if we are allowed to...
if ($page && intval(PConfig::get($local_uid, 'system', 'post_joingroup'))) {
$profile = dba::selectFirst('profile', ['hide-friends'], ['is-default' => true, 'uid' => $local_uid]);
if (x($profile, 'hide-friends') === 0) {
$self = dba::selectFirst('contact', [], ['self' => true, 'uid' => $local_uid]);
if (DBM::is_result($self)) {
$arr = [];
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid);
$arr['uid'] = $local_uid;
$arr['contact-id'] = $self['id'];
$arr['wall'] = 1;
$arr['type'] = 'wall';
$arr['gravity'] = 0;
$arr['origin'] = 1;
$arr['author-name'] = $arr['owner-name'] = $self['name'];
$arr['author-link'] = $arr['owner-link'] = $self['url'];
$arr['author-avatar'] = $arr['owner-avatar'] = $self['thumb'];
$A = '[url=' . $self['url'] . ']' . $self['name'] . '[/url]';
$B = '[url=' . $combined['url'] . ']' . $combined['name'] . '[/url]';
$BPhoto = '[url=' . $combined['url'] . ']' . '[img]' . $combined['thumb'] . '[/img][/url]';
$arr['verb'] = ACTIVITY_JOIN;
$arr['object-type'] = ACTIVITY_OBJ_GROUP;
$arr['body'] = L10n::t('%1$s has joined %2$s', $A, $B) . "\n\n\n" . $BPhoto;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_GROUP . '</type><title>' . $combined['name'] . '</title>'
. '<id>' . $combined['url'] . '/' . $combined['name'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $combined['url'] . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $combined['thumb'] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n";
$arr['allow_cid'] = $user['allow_cid'];
$arr['allow_gid'] = $user['allow_gid'];
$arr['deny_cid'] = $user['deny_cid'];
$arr['deny_gid'] = $user['deny_gid'];
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
}
}
}
System::xmlExit(0); // Success System::xmlExit(0); // Success
return; // NOTREACHED return; // NOTREACHED
////////////////////// End of this scenario /////////////////////////////////////////////// ////////////////////// End of this scenario ///////////////////////////////////////////////

View file

@ -577,7 +577,6 @@ function dfrn_request_content(App $a)
'dfrn_id' => $r[0]['issued-id'], 'dfrn_id' => $r[0]['issued-id'],
'intro_id' => $intro[0]['id'], 'intro_id' => $intro[0]['id'],
'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0), 'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
'activity' => intval(PConfig::get($r[0]['uid'], 'system', 'post_newfriend'))
]; ];
dfrn_confirm_post($a, $handsfree); dfrn_confirm_post($a, $handsfree);
} }

View file

@ -173,7 +173,6 @@ function notifications_content(App $a) {
'$fullname' => $it['name'], '$fullname' => $it['name'],
'$url' => $it['url'], '$url' => $it['url'],
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$activity' => ['activity', L10n::t('Post a new friend activity'), $it['post_newfriend'], L10n::t('if applicable')],
'$knowyou' => $it['knowyou'], '$knowyou' => $it['knowyou'],
'$approve' => L10n::t('Approve'), '$approve' => L10n::t('Approve'),
@ -252,7 +251,6 @@ function notifications_content(App $a) {
'$gender' => $it['gender'], '$gender' => $it['gender'],
'$lbl_gender' => L10n::t('Gender:'), '$lbl_gender' => L10n::t('Gender:'),
'$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''], '$hidden' => ['hidden', L10n::t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$activity' => ['activity', L10n::t('Post a new friend activity'), $it['post_newfriend'], L10n::t('if applicable')],
'$url' => $it['url'], '$url' => $it['url'],
'$zrl' => $it['zrl'], '$zrl' => $it['zrl'],
'$lbl_url' => L10n::t('Profile URL'), '$lbl_url' => L10n::t('Profile URL'),

View file

@ -403,9 +403,6 @@ function profiles_post(App $a) {
$comma2 = (($region && $country_name) ? ', ' : ''); $comma2 = (($region && $country_name) ? ', ' : '');
$value = $locality . $comma1 . $region . $comma2 . $country_name; $value = $locality . $comma1 . $region . $comma2 . $country_name;
} }
profile_activity($changes,$value);
} }
$r = q("UPDATE `profile` $r = q("UPDATE `profile`
@ -510,96 +507,6 @@ function profiles_post(App $a) {
} }
} }
function profile_activity($changed, $value) {
$a = get_app();
if (! local_user() || ! is_array($changed) || ! count($changed)) {
return;
}
if ($a->user['hidewall'] || Config::get('system', 'block_public')) {
return;
}
if (! PConfig::get(local_user(), 'system', 'post_profilechange')) {
return;
}
require_once 'include/items.php';
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
intval(local_user())
);
if (! DBM::is_result($self)) {
return;
}
$arr = [];
$arr['guid'] = get_guid(32);
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
$arr['uid'] = local_user();
$arr['contact-id'] = $self[0]['id'];
$arr['wall'] = 1;
$arr['type'] = 'wall';
$arr['gravity'] = 0;
$arr['origin'] = 1;
$arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
$arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
$arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
$arr['verb'] = ACTIVITY_UPDATE;
$arr['object-type'] = ACTIVITY_OBJ_PROFILE;
$A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
$changes = '';
$t = count($changed);
$z = 0;
foreach ($changed as $ch) {
if (strlen($changes)) {
if ($z == ($t - 1)) {
$changes .= L10n::t(' and ');
} else {
$changes .= ', ';
}
}
$z ++;
$changes .= $ch;
}
$prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . L10n::t('public profile') . '[/url]';
if ($t == 1 && strlen($value)) {
$message = L10n::t('%1$s changed %2$s to &ldquo;%3$s&rdquo;', $A, $changes, $value);
$message .= "\n\n" . L10n::t(' - Visit %1$s\'s %2$s', $A, $prof);
} else {
$message = L10n::t('%1$s has an updated %2$s, changing %3$s.', $A, $prof, $changes);
}
$arr['body'] = $message;
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
. '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
$arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
$arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
$arr['object'] .= '</link></object>' . "\n";
$arr['allow_cid'] = $a->user['allow_cid'];
$arr['allow_gid'] = $a->user['allow_gid'];
$arr['deny_cid'] = $a->user['deny_cid'];
$arr['deny_gid'] = $a->user['deny_gid'];
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
}
function profiles_content(App $a) { function profiles_content(App $a) {
if (! local_user()) { if (! local_user()) {

View file

@ -442,9 +442,6 @@ function settings_post(App $a)
$suggestme = ((x($_POST, 'suggestme')) ? intval($_POST['suggestme']) : 0); $suggestme = ((x($_POST, 'suggestme')) ? intval($_POST['suggestme']) : 0);
$hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
$hidewall = (($_POST['hidewall'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
$email_textonly = (($_POST['email_textonly'] == 1) ? 1 : 0); $email_textonly = (($_POST['email_textonly'] == 1) ? 1 : 0);
$detailed_notif = (($_POST['detailed_notif'] == 1) ? 1 : 0); $detailed_notif = (($_POST['detailed_notif'] == 1) ? 1 : 0);
@ -558,9 +555,6 @@ function settings_post(App $a)
PConfig::set(local_user(), 'expire', 'network_only', $expire_network_only); PConfig::set(local_user(), 'expire', 'network_only', $expire_network_only);
PConfig::set(local_user(), 'system', 'suggestme', $suggestme); PConfig::set(local_user(), 'system', 'suggestme', $suggestme);
PConfig::set(local_user(), 'system', 'post_newfriend', $post_newfriend);
PConfig::set(local_user(), 'system', 'post_joingroup', $post_joingroup);
PConfig::set(local_user(), 'system', 'post_profilechange', $post_profilechange);
PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly); PConfig::set(local_user(), 'system', 'email_textonly', $email_textonly);
PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif); PConfig::set(local_user(), 'system', 'detailed_notif', $detailed_notif);
@ -1020,9 +1014,6 @@ function settings_content(App $a)
$expire_photos = PConfig::get(local_user(), 'expire', 'photos', false); $expire_photos = PConfig::get(local_user(), 'expire', 'photos', false);
$expire_network_only = PConfig::get(local_user(), 'expire', 'network_only', false); $expire_network_only = PConfig::get(local_user(), 'expire', 'network_only', false);
$suggestme = PConfig::get(local_user(), 'system', 'suggestme', false); $suggestme = PConfig::get(local_user(), 'system', 'suggestme', false);
$post_newfriend = PConfig::get(local_user(), 'system', 'post_newfriend', false);
$post_joingroup = PConfig::get(local_user(), 'system', 'post_joingroup', false);
$post_profilechange = PConfig::get(local_user(), 'system', 'post_profilechange', false);
// nowarn_insecure // nowarn_insecure
@ -1247,10 +1238,6 @@ function settings_content(App $a)
'$h_not' => L10n::t('Notification Settings'), '$h_not' => L10n::t('Notification Settings'),
'$activity_options' => L10n::t('By default post a status message when:'),
'$post_newfriend' => ['post_newfriend', L10n::t('accepting a friend request'), $post_newfriend, ''],
'$post_joingroup' => ['post_joingroup', L10n::t('joining a forum/community'), $post_joingroup, ''],
'$post_profilechange' => ['post_profilechange', L10n::t('making an <em>interesting</em> profile change'), $post_profilechange, ''],
'$lbl_not' => L10n::t('Send a notification email when:'), '$lbl_not' => L10n::t('Send a notification email when:'),
'$notify1' => ['notify1', L10n::t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''], '$notify1' => ['notify1', L10n::t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''],
'$notify2' => ['notify2', L10n::t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''], '$notify2' => ['notify2', L10n::t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''],

View file

@ -2386,78 +2386,6 @@ class Diaspora
['id' => $contact["id"], 'uid' => $importer["uid"]] ['id' => $contact["id"], 'uid' => $importer["uid"]]
); );
} }
// send notification
$r = q(
"SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
intval($importer["uid"])
);
if ($r && !$r[0]["hide-friends"] && !$contact["hidden"] && intval(PConfig::get($importer["uid"], "system", "post_newfriend"))) {
$self = q(
"SELECT * FROM `contact` WHERE `self` AND `uid` = %d LIMIT 1",
intval($importer["uid"])
);
// they are not CONTACT_IS_FOLLOWER anymore but that's what we have in the array
if ($self && $contact["rel"] == CONTACT_IS_FOLLOWER) {
$arr = [];
$arr["protocol"] = PROTOCOL_DIASPORA;
$arr["uri"] = $arr["parent-uri"] = item_new_uri($a->get_hostname(), $importer["uid"]);
$arr["uid"] = $importer["uid"];
$arr["contact-id"] = $self[0]["id"];
$arr["wall"] = 1;
$arr["type"] = 'wall';
$arr["gravity"] = 0;
$arr["origin"] = 1;
$arr["author-name"] = $arr["owner-name"] = $self[0]["name"];
$arr["author-link"] = $arr["owner-link"] = $self[0]["url"];
$arr["author-avatar"] = $arr["owner-avatar"] = $self[0]["thumb"];
$arr["verb"] = ACTIVITY_FRIEND;
$arr["object-type"] = ACTIVITY_OBJ_PERSON;
$A = "[url=".$self[0]["url"]."]".$self[0]["name"]."[/url]";
$B = "[url=".$contact["url"]."]".$contact["name"]."[/url]";
$BPhoto = "[url=".$contact["url"]."][img]".$contact["thumb"]."[/img][/url]";
$arr["body"] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$BPhoto;
$arr["object"] = self::constructNewFriendObject($contact);
$user = dba::selectFirst('user', ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'], ['uid' => $importer["uid"]]);
$arr["allow_cid"] = $user["allow_cid"];
$arr["allow_gid"] = $user["allow_gid"];
$arr["deny_cid"] = $user["deny_cid"];
$arr["deny_gid"] = $user["deny_gid"];
$i = Item::insert($arr);
if ($i) {
Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
}
}
}
}
/**
* @brief Creates a XML object for a "new friend" message
*
* @param array $contact Array of the contact
*
* @return string The XML
*/
private static function constructNewFriendObject($contact)
{
$objtype = ACTIVITY_OBJ_PERSON;
$link = '<link rel="alternate" type="text/html" href="'.$contact["url"].'" />'."\n".
'<link rel="photo" type="image/jpeg" href="'.$contact["thumb"].'" />'."\n";
$xmldata = ["object" => ["type" => $objtype,
"title" => $contact["name"],
"id" => $contact["url"]."/".$contact["name"],
"link" => $link]];
return XML::fromArray($xmldata, $xml, true);
} }
/** /**

View file

@ -20,7 +20,6 @@
<form class="intro-approve-form" action="dfrn_confirm" method="post"> <form class="intro-approve-form" action="dfrn_confirm" method="post">
{{include file="field_checkbox.tpl" field=$hidden}} {{include file="field_checkbox.tpl" field=$hidden}}
{{include file="field_checkbox.tpl" field=$activity}}
<input type="hidden" name="dfrn_id" value="{{$dfrn_id}}" > <input type="hidden" name="dfrn_id" value="{{$dfrn_id}}" >
<input type="hidden" name="intro_id" value="{{$intro_id}}" > <input type="hidden" name="intro_id" value="{{$intro_id}}" >
<input type="hidden" name="contact_id" value="{{$contact_id}}" > <input type="hidden" name="contact_id" value="{{$contact_id}}" >

View file

@ -114,13 +114,6 @@
<div class="settings-content-block"> <div class="settings-content-block">
<div id="settings-notifications"> <div id="settings-notifications">
<div id="settings-activity-desc">{{$activity_options}}</div>
{{include file="field_checkbox.tpl" field=$post_newfriend}}
{{include file="field_checkbox.tpl" field=$post_joingroup}}
{{include file="field_checkbox.tpl" field=$post_profilechange}}
<div id="settings-notify-desc">{{$lbl_not}}</div> <div id="settings-notify-desc">{{$lbl_not}}</div>
<div class="group"> <div class="group">

View file

@ -50,7 +50,6 @@
<h3 class="heading">{{$fullname}}{{if $addr}}&nbsp;({{$addr}}){{/if}}</h3> <h3 class="heading">{{$fullname}}{{if $addr}}&nbsp;({{$addr}}){{/if}}</h3>
<form class="intro-approve-form" action="dfrn_confirm" method="post"> <form class="intro-approve-form" action="dfrn_confirm" method="post">
{{include file="field_checkbox.tpl" field=$hidden}} {{include file="field_checkbox.tpl" field=$hidden}}
{{include file="field_checkbox.tpl" field=$activity}}
<input type="hidden" name="dfrn_id" value="{{$dfrn_id}}" > <input type="hidden" name="dfrn_id" value="{{$dfrn_id}}" >
<input type="hidden" name="intro_id" value="{{$intro_id}}" > <input type="hidden" name="intro_id" value="{{$intro_id}}" >
<input type="hidden" name="contact_id" value="{{$contact_id}}" > <input type="hidden" name="contact_id" value="{{$contact_id}}" >

View file

@ -171,15 +171,6 @@
<div class="section-content-tools-wrapper"> <div class="section-content-tools-wrapper">
<div id="settings-notifications"> <div id="settings-notifications">
<div id="settings-activity-desc"><h4>{{$activity_options}}</h4></div>
<div class="group">
{{include file="field_checkbox.tpl" field=$post_newfriend}}
{{include file="field_checkbox.tpl" field=$post_joingroup}}
{{include file="field_checkbox.tpl" field=$post_profilechange}}
</div>
<div id="settings-notify-desc"><h4>{{$lbl_not}}</h4></div> <div id="settings-notify-desc"><h4>{{$lbl_not}}</h4></div>
<div class="group"> <div class="group">

View file

@ -110,13 +110,6 @@
<h3 class="settings-heading">{{$h_not}}</h3> <h3 class="settings-heading">{{$h_not}}</h3>
<div id="settings-notifications"> <div id="settings-notifications">
<div id="settings-activity-desc">{{$activity_options}}</div>
{{include file="field_checkbox.tpl" field=$post_newfriend}}
{{include file="field_checkbox.tpl" field=$post_joingroup}}
{{include file="field_checkbox.tpl" field=$post_profilechange}}
<div id="settings-notify-desc">{{$lbl_not}}</div> <div id="settings-notify-desc">{{$lbl_not}}</div>
<div class="group"> <div class="group">

View file

@ -4677,9 +4677,6 @@ div #datebrowse-sidebar.widget {
width: 75px; width: 75px;
} }
#id_post_newfriend,
#id_post_joingroup,
#id_post_profilechange,
#id_notify1, #id_notify1,
#id_notify2, #id_notify2,
#id_notify3, #id_notify3,