Skip to content

Commit

Permalink
set proper relation for diaspora in mod_follow
Browse files Browse the repository at this point in the history
  • Loading branch information
friendika committed Aug 16, 2011
1 parent 2409412 commit f7a1674
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mod/dfrn_confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) {

if($r[0]['network'] === NETWORK_DIASPORA) {
require_once('include_diaspora.php');
diaspora_share($user[0],$r[0]);
$ret = diaspora_share($user[0],$r[0]);
logger('mod_follow: diaspora_share returns: ' . $ret);
}

require_once('include/items.php');
Expand Down
11 changes: 9 additions & 2 deletions mod/follow.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function follow_post(&$a) {
$writeable = 1;

}
if($ret['network'] === NETWORK_DIASPORA)
$writeable = 1;

// check if we already have a contact
// the poll url is more reliable than the profile url, as we may have
Expand All @@ -83,7 +85,7 @@ function follow_post(&$a) {

if(count($r)) {
// update contact
if($r[0]['rel'] == CONTACT_IS_FOLLOWER) {
if($r[0]['rel'] == CONTACT_IS_FOLLOWER || ($network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval(CONTACT_IS_FRIEND),
intval($r[0]['id']),
Expand All @@ -92,6 +94,11 @@ function follow_post(&$a) {
}
}
else {

$new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
if($ret['network'] === NETWORK_DIASPORA)
$new_relation = CONTACT_IS_FOLLOWER;

// create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`,
`writable`, `blocked`, `readonly`, `pending` )
Expand All @@ -107,7 +114,7 @@ function follow_post(&$a) {
dbesc($ret['nick']),
dbesc($ret['photo']),
dbesc($ret['network']),
intval(($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING),
intval($new_relation),
intval($ret['priority']),
intval($writeable)
);
Expand Down

0 comments on commit f7a1674

Please sign in to comment.