progress on unfriending
This commit is contained in:
parent
159a347c01
commit
ad36ccdbc8
@ -263,8 +263,6 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function contact_remove($channel_id, $abook_id) {
|
function contact_remove($channel_id, $abook_id) {
|
||||||
|
|
||||||
if((! $channel_id) || (! $abook_id))
|
if((! $channel_id) || (! $abook_id))
|
||||||
@ -293,31 +291,37 @@ function contact_remove($channel_id, $abook_id) {
|
|||||||
if($abook['abook_flags'] & ABOOK_FLAG_SELF)
|
if($abook['abook_flags'] & ABOOK_FLAG_SELF)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
q("delete from item where author_xchan = '%s' and uid = %d",
|
|
||||||
|
$r = q("select * from item where author_xchan = '%s' and uid = %d",
|
||||||
dbesc($abook['abook_xchan']),
|
dbesc($abook['abook_xchan']),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
|
if($r) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
drop_item($rr,false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
q("delete from abook where abook_id = %d and abook_channel = %d limit 1",
|
q("delete from abook where abook_id = %d and abook_channel = %d limit 1",
|
||||||
intval($abook['abook_id']),
|
intval($abook['abook_id']),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
$r = q("delete from event where event_xchan = '%s' and uid = %d",
|
||||||
// FIXME
|
dbesc($abook['abook_xchan']),
|
||||||
q("DELETE FROM `photo` WHERE `contact-id` = %d ",
|
intval($channel_id)
|
||||||
intval($id)
|
|
||||||
);
|
);
|
||||||
q("DELETE FROM `mail` WHERE `contact-id` = %d ",
|
|
||||||
intval($id)
|
$r = q("delete from group_member where xchan = '%s' and uid = %d",
|
||||||
|
dbesc($abook['abook_xchan']),
|
||||||
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
q("DELETE FROM `event` WHERE `cid` = %d ",
|
|
||||||
intval($id)
|
$r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and uid = %d ",
|
||||||
|
dbesc($abook['abook_xchan']),
|
||||||
|
dbesc($abook['abook_xchan']),
|
||||||
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
q("DELETE FROM `queue` WHERE `cid` = %d ",
|
|
||||||
intval($id)
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
21
mod/post.php
21
mod/post.php
@ -309,17 +309,26 @@ function post_post(&$a) {
|
|||||||
if(array_key_exists('recipients',$data))
|
if(array_key_exists('recipients',$data))
|
||||||
$recipients = $data['recipients'];
|
$recipients = $data['recipients'];
|
||||||
|
|
||||||
|
|
||||||
if($msgtype === 'purge') {
|
if($msgtype === 'purge') {
|
||||||
if($recipients) {
|
if($recipients) {
|
||||||
// basically this means "unfriend"
|
// basically this means "unfriend"
|
||||||
foreach($recipients as $recip) {
|
foreach($recipients as $recip) {
|
||||||
|
$r = q("select channel.*,xchan.* from channel
|
||||||
|
left join xchan on channel_hash = xchan_hash
|
||||||
|
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
|
||||||
|
dbesc($recip['guid']),
|
||||||
|
dbesc($recip['guid_sig'])
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
$r = q("select abook_id from abook where uid = %d and abook_xchan = '%s' limit 1",
|
||||||
|
intval($r[0]['channel_id']),
|
||||||
|
dbesc(base64url_encode(hash('whirlpool',$sender['guid'] . $sender['guid_sig'], true)))
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
contact_remove($r[0]['channel_id'],$r[0]['abook_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Unfriend everybody - basically this means the channel has committed suicide
|
// Unfriend everybody - basically this means the channel has committed suicide
|
||||||
|
Reference in New Issue
Block a user