aboutsummaryrefslogtreecommitdiffstats
path: root/include/follow.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/follow.php')
-rw-r--r--include/follow.php77
1 files changed, 23 insertions, 54 deletions
diff --git a/include/follow.php b/include/follow.php
index a094a979f..10bcddf2b 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -1,4 +1,4 @@
-<?php
+<?php /** @file */
//
@@ -11,7 +11,7 @@
require_once('include/zot.php');
-function new_contact($uid,$url,$channel,$interactive = false) {
+function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) {
$result = array('success' => false,'message' => '');
@@ -60,6 +60,11 @@ function new_contact($uid,$url,$channel,$interactive = false) {
return $result;
}
+ // Premium channel, set confirm before callback to avoid recursion
+
+ if(array_key_exists('connect_url',$j) && (! $confirm))
+ goaway(zid($j['connect_url']));
+
// check service class limits
@@ -111,7 +116,10 @@ function new_contact($uid,$url,$channel,$interactive = false) {
if((local_user()) && $uid == local_user()) {
$aid = get_account_id();
- $hash = $a->observer['xchan_hash'];
+ $hash = get_observer_hash();
+ $ch = $a->get_channel();
+ $default_group = $ch['channel_default_group'];
+
}
else {
$r = q("select * from channel where channel_id = %d limit 1",
@@ -123,6 +131,7 @@ function new_contact($uid,$url,$channel,$interactive = false) {
}
$aid = $r[0]['channel_account_id'];
$hash = $r[0]['channel_hash'];
+ $default_group = $r[0]['channel_default_group'];
}
if($hash == $xchan_hash) {
@@ -141,12 +150,13 @@ function new_contact($uid,$url,$channel,$interactive = false) {
);
}
else {
- $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_created, abook_updated )
- values( %d, %d, '%s', %d, '%s', '%s' ) ",
+ $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated )
+ values( %d, %d, '%s', %d, %d, '%s', '%s' ) ",
intval($aid),
intval($uid),
dbesc($xchan_hash),
intval($their_perms),
+ intval(PERMS_W_STREAM|PERMS_W_MAIL),
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
@@ -160,62 +170,21 @@ function new_contact($uid,$url,$channel,$interactive = false) {
dbesc($xchan_hash),
intval($uid)
);
- if($r)
+ if($r) {
$result['abook'] = $r[0];
-
- // Then send a ping/message to the other side
-
-
-/*
-
- $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
- `writable`, `hidden`, `blocked`, `readonly`, `pending` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0) ",
- intval($uid),
- dbesc(datetime_convert()),
- dbesc($ret['url']),
- dbesc(normalise_link($ret['url'])),
- dbesc($ret['addr']),
- dbesc($ret['alias']),
- dbesc($ret['batch']),
- dbesc($ret['notify']),
- dbesc($ret['poll']),
- dbesc($ret['poco']),
- dbesc($ret['name']),
- dbesc($ret['nick']),
- dbesc($ret['photo']),
- dbesc($ret['network']),
- dbesc($ret['pubkey']),
- intval($new_relation),
- intval($ret['priority']),
- intval($writeable),
- intval($hidden)
- );
+ proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']);
}
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($ret['url']),
- intval($uid)
- );
-
- if(! count($r)) {
- $result['message'] .= t('Unable to retrieve contact information.') . EOL;
- return $result;
- }
+ /** If there is a default group for this channel, add this member to it */
- $contact = $r[0];
- $contact_id = $r[0]['id'];
-
-
- $g = q("select def_gid from user where uid = %d limit 1",
- intval($uid)
- );
- if($g && intval($g[0]['def_gid'])) {
+ if($default_group) {
require_once('include/group.php');
- group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
+ $g = group_rec_byhash($uid,$default_group);
+ if($g)
+ group_add_member($uid,'',$xchan_hash,$g['id']);
}
-*/
+ // Then send a ping/message to the other side
$result['success'] = true;