Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 2f80fdae authored by Mario's avatar Mario

Merge branch 'dev'

parents c5703306 9507f191
...@@ -1570,7 +1570,7 @@ class Activity { ...@@ -1570,7 +1570,7 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type); $s['verb'] = self::activity_decode_mapper($act->type);
if($act->type === 'Tombstone' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) { if($act->type === 'Tombstone' || $act-type === 'Delete' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
$s['item_deleted'] = 1; $s['item_deleted'] = 1;
} }
......
...@@ -2037,7 +2037,7 @@ class Libzot { ...@@ -2037,7 +2037,7 @@ class Libzot {
$item_found = false; $item_found = false;
$post_id = 0; $post_id = 0;
$r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1", and mid = '%s' and uid = %d limit 1",
dbesc($sender), dbesc($sender),
dbesc($sender), dbesc($sender),
...@@ -2047,10 +2047,12 @@ class Libzot { ...@@ -2047,10 +2047,12 @@ class Libzot {
); );
if($r) { if($r) {
if($r[0]['author_xchan'] === $sender || $r[0]['owner_xchan'] === $sender || $r[0]['source_xchan'] === $sender) $stored = $r[0];
if($stored['author_xchan'] === $sender || $stored['owner_xchan'] === $sender || $stored['source_xchan'] === $sender)
$ownership_valid = true; $ownership_valid = true;
$post_id = $r[0]['id']; $post_id = $stored['id'];
$item_found = true; $item_found = true;
} }
else { else {
...@@ -2074,8 +2076,27 @@ class Libzot { ...@@ -2074,8 +2076,27 @@ class Libzot {
return false; return false;
} }
if ($stored['resource_type'] === 'event') {
$i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($stored['resource_id']),
intval($uid)
);
if ($i) {
if ($i[0]['event_xchan'] === $sender) {
q("delete from event where event_hash = '%s' and uid = %d",
dbesc($stored['resource_id']),
intval($uid)
);
}
else {
logger('delete linked event: not owner');
return;
}
}
}
if($item_found) { if($item_found) {
if(intval($r[0]['item_deleted'])) { if(intval($stored['item_deleted'])) {
logger('delete_imported_item: item was already deleted'); logger('delete_imported_item: item was already deleted');
if(! $relay) if(! $relay)
return false; return false;
...@@ -2087,10 +2108,10 @@ class Libzot { ...@@ -2087,10 +2108,10 @@ class Libzot {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing // back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact. // this information from the metadata should have no other discernible impact.
if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) { if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d", q("update item set item_origin = 0 where id = %d and uid = %d",
intval($r[0]['id']), intval($stored['id']),
intval($r[0]['uid']) intval($stored['uid'])
); );
} }
} }
......
...@@ -191,7 +191,7 @@ class NativeWiki { ...@@ -191,7 +191,7 @@ class NativeWiki {
return array('item' => null, 'success' => false); return array('item' => null, 'success' => false);
} }
else { else {
$drop = drop_item($item['id'], false, DROPITEM_NORMAL, true); $drop = drop_item($item['id'], false, DROPITEM_NORMAL);
} }
info( t('Wiki files deleted successfully')); info( t('Wiki files deleted successfully'));
......
This diff is collapsed.
...@@ -422,13 +422,67 @@ class Channel_calendar extends \Zotlabs\Web\Controller { ...@@ -422,13 +422,67 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($event_id), dbesc($event_id),
intval(local_channel()) intval(local_channel())
); );
if($r) { if($r) {
$r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d",
$sync_event['event_deleted'] = 1;
build_sync_packet(0,array('event' => array($sync_event)));
$i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d",
dbesc($event_id), dbesc($event_id),
intval(local_channel()) intval(local_channel())
); );
$sync_event['event_deleted'] = 1;
build_sync_packet(0,array('event' => array($sync_event))); if ($i) {
$can_delete = false;
$local_delete = true;
$ob_hash = get_observer_hash();
if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
$can_delete = true;
}
// The site admin can delete any post/item on the site.
// If the item originated on this site+channel the deletion will propagate downstream.
// Otherwise just the local copy is removed.
if(is_site_admin()) {
$local_delete = true;
if(intval($i[0]['item_origin']))
$can_delete = true;
}
if($can_delete || $local_delete) {
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
$complex = false;
if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) {
drop_item($i[0]['id']);
}
else {
// complex deletion that needs to propagate and be performed in phases
drop_item($i[0]['id'],true,DROPITEM_PHASE1);
$complex = true;
}
$ii = q("select * from item where id = %d",
intval($i[0]['id'])
);
if($ii) {
xchan_query($ii);
$sync_item = fetch_post_tags($ii);
build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
}
if($complex) {
tag_deliver($i[0]['uid'],$i[0]['id']);
}
}
}
killme(); killme();
} }
notice( t('Failed to remove event' ) . EOL); notice( t('Failed to remove event' ) . EOL);
......
...@@ -11,6 +11,9 @@ require_once('include/html2plain.php'); ...@@ -11,6 +11,9 @@ require_once('include/html2plain.php');
class Events extends \Zotlabs\Web\Controller { class Events extends \Zotlabs\Web\Controller {
function post() { function post() {
// this module is deprecated
return;
logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA); logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA);
...@@ -245,6 +248,9 @@ class Events extends \Zotlabs\Web\Controller { ...@@ -245,6 +248,9 @@ class Events extends \Zotlabs\Web\Controller {
function get() { function get() {
// this module is deprecated
return;
if(argc() > 2 && argv(1) == 'ical') { if(argc() > 2 && argv(1) == 'ical') {
$event_id = argv(2); $event_id = argv(2);
......
...@@ -25,6 +25,10 @@ class Mail extends \Zotlabs\Web\Controller { ...@@ -25,6 +25,10 @@ class Mail extends \Zotlabs\Web\Controller {
$expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE);
$raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0); $raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0);
$mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode'); $mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode');
$sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : '');
if(strpos($sig,'b64.') === 0)
$sig = base64_decode(str_replace('b64.', '', $sig));
if($preview) { if($preview) {
...@@ -123,7 +127,7 @@ class Mail extends \Zotlabs\Web\Controller { ...@@ -123,7 +127,7 @@ class Mail extends \Zotlabs\Web\Controller {
// We have a local_channel, let send_message use the session channel and save a lookup // We have a local_channel, let send_message use the session channel and save a lookup
$ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig);
if($ret['success']) { if($ret['success']) {
xchan_mail_query($ret['mail']); xchan_mail_query($ret['mail']);
...@@ -396,8 +400,9 @@ class Mail extends \Zotlabs\Web\Controller { ...@@ -396,8 +400,9 @@ class Mail extends \Zotlabs\Web\Controller {
'can_recall' => ($channel['channel_hash'] == $message['from_xchan']), 'can_recall' => ($channel['channel_hash'] == $message['from_xchan']),
'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'), 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'),
'sig' => base64_encode($message['sig'])
); );
$seen = $message['seen']; $seen = $message['seen'];
} }
......
...@@ -193,7 +193,9 @@ class Receiver { ...@@ -193,7 +193,9 @@ class Receiver {
case 'response': // upstream message case 'response': // upstream message
case 'sync': case 'sync':
default: default:
$this->response = $this->handler->Notify($this->data,$this->hub); if ($this->sender) {
$this->response = $this->handler->Notify($this->data,$this->hub);
}
break; break;
} }
......
...@@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { ...@@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
function attach_drop_photo($channel_id,$resource) { function attach_drop_photo($channel_id,$resource) {
$x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d and item_deleted = 0",
dbesc($resource), dbesc($resource),
intval($channel_id) intval($channel_id)
); );
if($x) { if($x) {
drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); $stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1);
$interactive = (($x[0]['item_hidden']) ? false : true);
drop_item($x[0]['id'], $interactive, $stage);
} }
$r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1", $r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1",
......
...@@ -280,20 +280,6 @@ function get_features($filtered = true, $level = (-1)) { ...@@ -280,20 +280,6 @@ function get_features($filtered = true, $level = (-1)) {
], ],
'events' => [
t('Events'),
[
'events_cal_first_day',
t('Start calendar week on Monday'),
t('Default is Sunday'),
false,
get_config('feature_lock','events_cal_first_day')
]
],
'manage' => [ 'manage' => [
t('Manage'), t('Manage'),
......
...@@ -1177,7 +1177,7 @@ function sync_files($channel, $files) { ...@@ -1177,7 +1177,7 @@ function sync_files($channel, $files) {
convert_oldfields($att,'data','content'); convert_oldfields($att,'data','content');
if($att['deleted']) { if($att['deleted']) {
attach_delete($channel,$att['hash']); attach_delete($channel['channel_id'],$att['hash']);
continue; continue;
} }
...@@ -1383,12 +1383,14 @@ function sync_files($channel, $files) { ...@@ -1383,12 +1383,14 @@ function sync_files($channel, $files) {
); );
} }
if(intval($p['imgscale']) === 0 && $p['os_storage']) if(intval($p['os_storage'])) {
$p['content'] = $store_path; $p['content'] = $store_path . ((intval($p['imgscale'])) ? '-' . $p['imgscale'] : '');
else }
else {
$p['content'] = (($p['content'])? base64_decode($p['content']) : ''); $p['content'] = (($p['content'])? base64_decode($p['content']) : '');
}
if(intval($p['imgscale']) && (! empty($p['content']))) { if (intval($p['imgscale']) && ((intval($p['os_storage'])) || (! $p['content']))) {
$time = datetime_convert(); $time = datetime_convert();
......
...@@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) { ...@@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) {
$x['to'] = encode_item_xchan($item['to']); $x['to'] = encode_item_xchan($item['to']);
$x['raw'] = $item['mail_raw']; $x['raw'] = $item['mail_raw'];
$x['mimetype'] = $item['mail_mimetype']; $x['mimetype'] = $item['mail_mimetype'];
$x['sig'] = $item['sig'];
if($item['attach']) if($item['attach'])
$x['attach'] = json_decode($item['attach'],true); $x['attach'] = json_decode($item['attach'],true);
...@@ -1516,6 +1517,9 @@ function get_mail_elements($x) { ...@@ -1516,6 +1517,9 @@ function get_mail_elements($x) {
$arr['expires'] = datetime_convert('UTC','UTC',$x['expires']); $arr['expires'] = datetime_convert('UTC','UTC',$x['expires']);
$arr['mail_flags'] = 0; $arr['mail_flags'] = 0;
if(array_key_exists('sig',$x))
$arr['sig'] = $x['sig'];
if($x['flags'] && is_array($x['flags'])) { if($x['flags'] && is_array($x['flags'])) {
if(in_array('recalled',$x['flags'])) { if(in_array('recalled',$x['flags'])) {
...@@ -3663,7 +3667,7 @@ function retain_item($id) { ...@@ -3663,7 +3667,7 @@ function retain_item($id) {
); );
} }
function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force = false) { function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL) {
$uid = 0; $uid = 0;
if(! local_channel() && ! remote_channel()) if(! local_channel() && ! remote_channel())
...@@ -3671,7 +3675,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force ...@@ -3671,7 +3675,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
if(count($items)) { if(count($items)) {
foreach($items as $item) { foreach($items as $item) {
$owner = drop_item($item,$interactive,$stage,$force); $owner = drop_item($item,$interactive,$stage);
if($owner && ! $uid) if($owner && ! $uid)
$uid = $owner; $uid = $owner;
} }
...@@ -3694,12 +3698,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force ...@@ -3694,12 +3698,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
// $stage = 1 => set deleted flag on the item and perform intial notifications // $stage = 1 => set deleted flag on the item and perform intial notifications
// $stage = 2 => perform low level delete at a later stage // $stage = 2 => perform low level delete at a later stage
function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) {
// These resource types have linked items that should only be removed at the same time
// as the linked resource; if we encounter one set it to item_hidden rather than item_deleted.
$linked_resource_types = [ 'photo' ];
// locate item to be deleted // locate item to be deleted
...@@ -3711,13 +3710,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal ...@@ -3711,13 +3710,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if(! $interactive) if(! $interactive)
return 0; return 0;
notice( t('Item not found.') . EOL); notice( t('Item not found.') . EOL);
goaway(z_root() . '/' . $_SESSION['return_url']); //goaway(z_root() . '/' . $_SESSION['return_url']);
} }
$item = $r[0]; $item = $r[0];
$linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
$ok_to_delete = false; $ok_to_delete = false;
// system deletion // system deletion
...@@ -3743,16 +3740,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal ...@@ -3743,16 +3740,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// set the deleted flag immediately on this item just in case the // set the deleted flag immediately on this item just in case the
// hook calls a remote process which loops. We'll delete it properly in a second. // hook calls a remote process which loops. We'll delete it properly in a second.
if(($linked_item) && (! $force)) { $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
$r = q("UPDATE item SET item_hidden = 1 WHERE id = %d", intval($item['id'])
intval($item['id']) );
);
}
else {
$r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
intval($item['id'])
);
}
$arr = [ $arr = [
'item' => $item, 'item' => $item,
...@@ -3792,14 +3782,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal ...@@ -3792,14 +3782,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) { if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) {
Master::Summon([ 'Notifier','drop',$notify_id ]); Master::Summon([ 'Notifier','drop',$notify_id ]);
} }
//goaway(z_root() . '/' . $_SESSION['return_url']);
goaway(z_root() . '/' . $_SESSION['return_url']);
} }
else { else {
if(! $interactive) if(! $interactive)
return 0; return 0;
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
goaway(z_root() . '/' . $_SESSION['return_url']); //goaway(z_root() . '/' . $_SESSION['return_url']);
} }
} }
...@@ -3814,11 +3803,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal ...@@ -3814,11 +3803,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
* @param boolean $force * @param boolean $force
* @return boolean * @return boolean
*/ */
function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) {
$linked_item = (($item['resource_id']) ? true : false);
logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA); logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA);
switch($stage) { switch($stage) {
case DROPITEM_PHASE2: case DROPITEM_PHASE2:
...@@ -3831,42 +3818,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { ...@@ -3831,42 +3818,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
break; break;
case DROPITEM_PHASE1: case DROPITEM_PHASE1:
if($linked_item && ! $force) { $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
$r = q("UPDATE item SET item_hidden = 1, dbesc(datetime_convert()),
changed = '%s', edited = '%s' WHERE id = %d", dbesc(datetime_convert()),
dbesc(datetime_convert()), intval($item['id'])
dbesc(datetime_convert()), );
intval($item['id'])
);
}
else {
$r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
);
}
break; break;
case DROPITEM_NORMAL: case DROPITEM_NORMAL:
default: default:
if($linked_item && ! $force) { $r = q("DELETE FROM item WHERE id = %d",
$r = q("UPDATE item SET item_hidden = 1, intval($item['id'])
changed = '%s', edited = '%s' WHERE id = %d", );
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
);
}
else {
$r = q("DELETE FROM item WHERE id = %d",
intval($item['id'])
);
}
break; break;
} }
// immediately remove local linked resources
if($item['resource_type'] === 'event') {
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($item['resource_id']),
intval($item['uid'])
);
$sync_data = $r[0];
$x = q("delete from event where event_hash = '%s' and uid = %d",
dbesc($item['resource_id']),
intval($item['uid'])
);
if($x) {
$sync_data['event_deleted'] = 1;
build_sync_packet($item['uid'], ['event' => [$sync_data]]);
}
}
if($item['resource_type'] === 'photo') {
attach_delete($item['uid'], $item['resource_id'], true );
$channel = channelx_by_n($item['uid']);
$sync_data = attach_export_data($channel, $item['resource_id'], true);
if($sync_data)
build_sync_packet($item['uid'], ['file' => [$sync_data]]);
}
// immediately remove any undesired profile likes. // immediately remove any undesired profile likes.
q("delete from likes where iid = %d and channel_id = %d", q("delete from likes where iid = %d and channel_id = %d",
......
...@@ -19,7 +19,7 @@ function mail_prepare_binary($item) { ...@@ -19,7 +19,7 @@ function mail_prepare_binary($item) {
// send a private message // send a private message
function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) { function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false, $sig = '') {
$ret = array('success' => false); $ret = array('success' => false);
$is_reply = false; $is_reply = false;
...@@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep ...@@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$subject = str_rot47(base64url_encode($subject)); $subject = str_rot47(base64url_encode($subject));
if(($body )&& (! $raw)) if(($body )&& (! $raw))
$body = str_rot47(base64url_encode($body)); $body = str_rot47(base64url_encode($body));
$sig = ''; // placeholder
$mimetype = ''; //placeholder $mimetype = ''; //placeholder
$r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw ) $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw )
......
...@@ -2241,7 +2241,7 @@ function delete_imported_item($sender, $item, $uid, $relay) { ...@@ -2241,7 +2241,7 @@ function delete_imported_item($sender, $item, $uid, $relay) {
$item_found = false; $item_found = false;
$post_id = 0; $post_id = 0;
$r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1", and mid = '%s' and uid = %d limit 1",
dbesc($sender['hash']), dbesc($sender['hash']),
dbesc($sender['hash']), dbesc($sender['hash']),
...@@ -2251,10 +2251,13 @@ function delete_imported_item($sender, $item, $uid, $relay) { ...@@ -2251,10 +2251,13 @@ function delete_imported_item($sender, $item, $uid, $relay) {
); );
if($r) { if($r) {
if($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash'])
$stored = $r[0];
if($stored['author_xchan'] === $sender['hash'] || $stored['owner_xchan'] === $sender['hash'] || $stored['source_xchan'] === $sender['hash'])
$ownership_valid = true; $ownership_valid = true;
$post_id = $r[0]['id']; $post_id = $stored['id'];
$item_found = true; $item_found = true;
} }
else { else {
...@@ -2278,10 +2281,29 @@ function delete_imported_item($sender, $item, $uid, $relay) { ...@@ -2278,10 +2281,29 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false; return false;
} }
if ($stored['resource_type'] === 'event') {
$i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
dbesc($stored['resource_id']),
intval($uid)
);
if ($i) {
if ($i[0]['event_xchan'] === $sender['hash']) {
q("delete from event where event_hash = '%s' and uid = %d",
dbesc($stored['resource_id']),
intval($uid)
);
}
else {
logger('delete linked event: not owner');
return;
}
}
}
require_once('include/items.php'); require_once('include/items.php');
if($item_found) {