aboutsummaryrefslogtreecommitdiffstats
path: root/include/connections.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/connections.php')
-rw-r--r--include/connections.php142
1 files changed, 80 insertions, 62 deletions
diff --git a/include/connections.php b/include/connections.php
index 87db7faa9..dcfcc3985 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -1,5 +1,6 @@
<?php /** @file */
+use Zotlabs\Daemon\Master;
function abook_store_lowlevel($arr) {
@@ -27,7 +28,8 @@ function abook_store_lowlevel($arr) {
'abook_profile' => ((array_key_exists('abook_profile',$arr)) ? $arr['abook_profile'] : ''),
'abook_incl' => ((array_key_exists('abook_incl',$arr)) ? $arr['abook_incl'] : ''),
'abook_excl' => ((array_key_exists('abook_excl',$arr)) ? $arr['abook_excl'] : ''),
- 'abook_instance' => ((array_key_exists('abook_instance',$arr)) ? $arr['abook_instance'] : '')
+ 'abook_instance' => ((array_key_exists('abook_instance',$arr)) ? $arr['abook_instance'] : ''),
+ 'abook_role' => ((array_key_exists('abook_role',$arr)) ? $arr['abook_role'] : '')
];
return create_table_from_array('abook',$store);
@@ -112,7 +114,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') {
// don't provide a connect button for transient or one-way identities
- if(in_array($xchan['xchan_network'],['rss','anon','unknown']) || strpos($xchan['xchan_addr'],'guest:') === 0) {
+ if(in_array($xchan['xchan_network'],['rss', 'anon', 'unknown', 'token'])) {
$connect = false;
}
@@ -127,7 +129,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') {
return replace_macros(get_markup_template('xchan_vcard.tpl'),array(
'$name' => $xchan['xchan_name'],
'$addr' => (($xchan['xchan_addr']) ? $xchan['xchan_addr'] : $xchan['xchan_url']),
- '$photo' => $xchan['xchan_photo_m'],
+ '$photo' => $xchan['xchan_photo_l'],
'$follow' => (($xchan['xchan_addr']) ? $xchan['xchan_addr'] : $xchan['xchan_url']),
'$link' => zid($xchan['xchan_url']),
'$connect' => $connect,
@@ -212,7 +214,7 @@ function mark_orphan_hubsxchans() {
return;
$r = q("UPDATE hubloc SET hubloc_error = 1 WHERE hubloc_error = 0
- AND hubloc_network IN ('zot6', 'zot') AND hubloc_connected < %s - INTERVAL %s",
+ AND hubloc_network = 'zot6' AND hubloc_connected < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('36 day')
);
@@ -272,6 +274,9 @@ function mark_orphan_hubsxchans() {
function remove_all_xchan_resources($xchan, $channel_id = 0) {
+ if(!$xchan)
+ return;
+
if(intval($channel_id)) {
@@ -281,34 +286,29 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
$dirmode = intval(get_config('system','directory_mode'));
-
$r = q("delete from photo where xchan = '%s'",
dbesc($xchan)
);
+
$r = q("select resource_id, resource_type, uid, id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ",
dbesc($xchan),
dbesc($xchan)
);
+
if($r) {
foreach($r as $rr) {
- drop_item($rr,false);
+ drop_item($rr['id'],false);
}
}
+
$r = q("delete from event where event_xchan = '%s'",
dbesc($xchan)
);
+
$r = q("delete from pgrp_member where xchan = '%s'",
dbesc($xchan)
);
- // Cannot delete just one side of the conversation since we do not allow
- // you to block private mail replies. This would leave open a gateway for abuse.
- // Both participants are owners of the conversation and both can remove it.
-
- $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )",
- dbesc($xchan),
- dbesc($xchan)
- );
$r = q("delete from xlink where ( xlink_xchan = '%s' or xlink_link = '%s' )",
dbesc($xchan),
dbesc($xchan)
@@ -318,7 +318,6 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
dbesc($xchan)
);
-
if($dirmode === false || $dirmode == DIRECTORY_MODE_NORMAL) {
$r = q("delete from xchan where xchan_hash = '%s'",
@@ -379,52 +378,22 @@ function contact_remove($channel_id, $abook_id) {
if(intval($abook['abook_self']))
return false;
- $r = q("select id, parent from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d and item_retained = 0 and item_starred = 0",
- dbesc($abook['abook_xchan']),
- dbesc($abook['abook_xchan']),
- intval($channel_id)
+ // if this is an atoken, delete the atoken record
+
+ $xchan = q("select * from xchan where xchan_hash = '%s'",
+ dbesc($abook['abook_xchan'])
);
- if($r) {
- $already_saved = [];
- foreach($r as $rr) {
- $w = $x = $y = null;
- // optimise so we only process newly seen parent items
- if (in_array($rr['parent'],$already_saved)) {
- continue;
- }
- // if this isn't the parent, fetch the parent's item_retained and item_starred to see if the conversation
- // should be retained
- if($rr['id'] != $rr['parent']) {
- $w = q("select id, item_retained, item_starred from item where id = %d",
- intval($rr['parent'])
- );
- if($w) {
- // see if the conversation was filed
- $x = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
- intval(TERM_OBJ_POST),
- intval($w[0]['id']),
- intval(TERM_FILE)
- );
- if (intval($w[0]['item_retained']) || intval($w[0]['item_starred']) || $x) {
- $already_saved[] = $rr['parent'];
- continue;
- }
- }
- }
- // see if this item was filed
- $y = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
- intval(TERM_OBJ_POST),
- intval($rr['id']),
- intval(TERM_FILE)
- );
- if ($y) {
- continue;
- }
- drop_item($rr['id'],false);
+ if (strpos($xchan['xchan_addr'],'guest:') === 0 && strpos($abook['abook_xchan'],'.')){
+ $atoken_guid = substr($abook['abook_xchan'],strrpos($abook['abook_xchan'],'.') + 1);
+ if ($atoken_guid) {
+ atoken_delete_and_sync($channel_id,$atoken_guid);
}
}
+ // remove items in the background as this can take some time
+ Master::Summon(['Delxitems', $channel_id, $abook['abook_xchan']]);
+
q("delete from abook where abook_id = %d and abook_channel = %d",
intval($abook['abook_id']),
intval($channel_id)
@@ -440,12 +409,6 @@ function contact_remove($channel_id, $abook_id) {
intval($channel_id)
);
- $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and channel_id = %d ",
- dbesc($abook['abook_xchan']),
- dbesc($abook['abook_xchan']),
- intval($channel_id)
- );
-
$r = q("delete from abconfig where chan = %d and xchan = '%s'",
intval($channel_id),
dbesc($abook['abook_xchan'])
@@ -459,7 +422,62 @@ function contact_remove($channel_id, $abook_id) {
return true;
}
+function remove_abook_items($channel_id, $xchan_hash) {
+
+ $r = q("select id from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d and item_retained = 0 and item_starred = 0",
+ dbesc($xchan_hash),
+ dbesc($xchan_hash),
+ intval($channel_id)
+ );
+ if (! $r) {
+ return;
+ }
+
+ $already_saved = [];
+ foreach ($r as $rr) {
+ $w = $x = $y = null;
+
+ // optimise so we only process newly seen parent items
+ if (in_array($rr['parent'], $already_saved)) {
+ continue;
+ }
+
+ // if this isn't the parent, fetch the parent's item_retained and item_starred to see if the conversation
+ // should be retained
+ if ($rr['id'] != $rr['parent']) {
+ $w = q("select id, item_retained, item_starred from item where id = %d",
+ intval($rr['parent'])
+ );
+
+ if ($w) {
+ // see if the conversation was filed
+ $x = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
+ intval(TERM_OBJ_POST),
+ intval($w[0]['id']),
+ intval(TERM_FILE)
+ );
+
+ if (intval($w[0]['item_retained']) || intval($w[0]['item_starred']) || $x) {
+ $already_saved[] = $rr['parent'];
+ continue;
+ }
+ }
+ }
+
+ // see if this item was filed
+ $y = q("select uid from term where otype = %d and oid = %d and ttype = %d limit 1",
+ intval(TERM_OBJ_POST),
+ intval($rr['id']),
+ intval(TERM_FILE)
+ );
+ if ($y) {
+ continue;
+ }
+
+ drop_item($rr['id'],false);
+ }
+}
function random_profile() {
$randfunc = db_getfunc('rand');