From 03756c65fc1c5bebfc4009bca32b5f681b5c1b21 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 28 Jul 2015 17:55:21 -0700 Subject: make superblock block a channel if it's an owner as well as the current author; add @hostname to event hashes to make their use in vcalendar more RFC compliant --- include/conversation.php | 2 +- include/event.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index fb012667e..76a2f47d1 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -597,7 +597,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ if($arr_blocked) { $blocked = false; foreach($arr_blocked as $b) { - if(($b) && ($item['author_xchan'] == $b)) { + if(($b) && (($item['author_xchan'] == $b) || ($item['owner_xchan'] == $b))) { $blocked = true; break; } diff --git a/include/event.php b/include/event.php index a5cd93215..784da0545 100644 --- a/include/event.php +++ b/include/event.php @@ -281,7 +281,7 @@ function event_store_event($arr) { if(array_key_exists('external_id',$arr)) $hash = $arr['external_id']; else - $hash = random_string(); + $hash = random_string() . '@' . get_app()->get_hostname(); $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid) -- cgit v1.2.3 From 4c83e9b6b49061cbd87ddb5e09976625e43c8394 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 28 Jul 2015 21:55:28 -0700 Subject: initial work on using sabre as a vcalendar parser --- include/event.php | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 784da0545..af828495b 100644 --- a/include/event.php +++ b/include/event.php @@ -1,4 +1,6 @@ VEVENT as $event) { + event_import_ical($event,$uid); + + } + } + + date_default_timezone_set($saved_timezone); + + logger('vobject: ' . print_r($ical,true)); + return true; + +// require_once('library/ical.php'); $ical = new ICal($f); if($ical) { $events = $ical->events(); @@ -400,6 +427,28 @@ function event_import_ical($ical, $uid) { $channel = $c[0]; $ev = array(); + + + + $dtstart = $event->DTSTART->getDateTime(); + if(($dtstart['timezone_type'] == 2) || (($dtstart['timezone_type'] == 3) && ($dtstart['timezone'] === 'UTC'))) { + $ev['adjust'] = 1; + } + else { + $ev['adjust'] = 0; + } + + $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtstart->format(\DateTime::W3C)); + + + +// logger('event: ' . print_r($event->DTSTART->getDateTime(),true)); + + + + + if($ical['CREATED']) $ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']); if($ical['LAST-MODIFIED']) -- cgit v1.2.3 From e3f605e242ed1bcb2da6a8ddf4bad1670583953a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 29 Jul 2015 16:30:00 -0700 Subject: PRIVACY: imported events --- include/event.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/event.php b/include/event.php index 784da0545..537121751 100644 --- a/include/event.php +++ b/include/event.php @@ -434,6 +434,7 @@ function event_import_ical($ical, $uid) { $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; $ev['private'] = 1; + $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; logger('storing event: ' . print_r($ev,true), LOGGER_ALL); $event = event_store_event($ev); -- cgit v1.2.3 From 845024e1e761f7b62df7031b738d77d46957ad74 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 29 Jul 2015 17:04:17 -0700 Subject: add connection filter to non-zot posts --- include/diaspora.php | 5 +++++ include/items.php | 3 +++ 2 files changed, 8 insertions(+) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 79d3909ca..74a56dd79 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1009,6 +1009,11 @@ function diaspora_post($importer,$xml,$msg) { return 202; } + if(! post_is_importable($datarray,$contact)) { + logger('diaspora_post: filtering this author.'); + return 202; + } + $result = item_store($datarray); return; diff --git a/include/items.php b/include/items.php index f0b7d6a7f..c807c1d5d 100755 --- a/include/items.php +++ b/include/items.php @@ -3762,6 +3762,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $author['owner_avatar'] = $contact['thumb']; } + if(! post_is_importable($datarray,$contact)) + continue; + logger('consume_feed: author ' . print_r($author,true),LOGGER_DEBUG); logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA); -- cgit v1.2.3 From 00fa2e2fe889d1f65f858d4dcb93ede4fdaa8636 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 29 Jul 2015 18:57:52 -0700 Subject: convert ics import to sabre/vobject --- include/event.php | 71 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index af828495b..a1fae617d 100644 --- a/include/event.php +++ b/include/event.php @@ -395,7 +395,7 @@ require_once('vendor/autoload.php'); date_default_timezone_set($saved_timezone); - logger('vobject: ' . print_r($ical,true)); +// logger('vobject: ' . print_r($ical,true)); return true; // require_once('library/ical.php'); @@ -428,10 +428,16 @@ function event_import_ical($ical, $uid) { $ev = array(); + if(! isset($ical->DTSTART)) { + logger('no event start'); + return false; + } + $dtstart = $ical->DTSTART->getDateTime(); - $dtstart = $event->DTSTART->getDateTime(); - if(($dtstart['timezone_type'] == 2) || (($dtstart['timezone_type'] == 3) && ($dtstart['timezone'] === 'UTC'))) { +// logger('dtstart: ' . var_export($dtstart,true)); + + if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) { $ev['adjust'] = 1; } else { @@ -442,49 +448,56 @@ function event_import_ical($ical, $uid) { $dtstart->format(\DateTime::W3C)); - -// logger('event: ' . print_r($event->DTSTART->getDateTime(),true)); + if(isset($ical->DTEND)) { + $dtend = $ical->DTEND->getDateTime(); + $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $dtend->format(\DateTime::W3C)); + } + else + $ev['nofinish'] = 1; + if($ev['start'] === $ev['finish']) + $ev['nofinish'] = 1; + if(isset($ical->CREATED)) { + $created = $ical->CREATED->getDateTime(); + $ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C)); + } + if(isset($ical->{'LAST-MODIFIED'})) { + $edited = $ical->{'LAST-MODIFIED'}->getDateTime(); + $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C)); + } - if($ical['CREATED']) - $ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']); - if($ical['LAST-MODIFIED']) - $ev['edited'] = datetime_convert('UTC','UTC',$ical['LAST-MODIFIED']); - if($ical['LOCATION']) - $ev['location'] = $ical['LOCATION']; - if($ical['DESCRIPTION']) - $ev['description'] = $ical['DESCRIPTION']; - if($ical['SUMMARY']) - $ev['summary'] = $ical['SUMMARY']; - if($ical['DTEND']) - $ev['finish'] = datetime_convert('UTC','UTC', $ical['DTEND']); - else - $ev['nofinish'] = 1; - $ev['start'] = datetime_convert('UTC','UTC',$ical['DTSTART']); - if(substr($ical['DTSTART'],-1) === 'Z') - $ev['adjust'] = 1; + if(isset($ical->LOCATION)) + $ev['location'] = (string) $ical->LOCATION; + if(isset($ical->DESCRIPTION)) + $ev['description'] = (string) $ical->DESCRIPTION; + if(isset($ical->SUMMARY)) + $ev['summary'] = (string) $ical->SUMMARY; - if($ical['UID']) { + if(isset($ical->UID)) { + $evuid = (string) $ical->UID; $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", - dbesc($ical['UID']), - intval($arr['uid']) + dbesc($evuid), + intval($uid) ); if($r) - $ev['event_hash'] = $ical['UID']; + $ev['event_hash'] = $evuid; else - $ev['external_id'] = $ical['UID']; + $ev['external_id'] = $evuid; } - if($ical['SUMMARY'] && $ical['DTSTART']) { + if($ev['summary'] && $ev['start']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; $ev['private'] = 1; + $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + - logger('storing event: ' . print_r($ev,true), LOGGER_ALL); +// logger('storing event: ' . print_r($ev,true), LOGGER_ALL); $event = event_store_event($ev); if($event) { $item_id = event_store_item($ev,$event); -- cgit v1.2.3 From 1097cd25830bc11d9aacf24f0e43322d6f397ca3 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 29 Jul 2015 19:01:25 -0700 Subject: minor cleanup --- include/event.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index b130ef47f..4e36f5090 100644 --- a/include/event.php +++ b/include/event.php @@ -395,21 +395,8 @@ require_once('vendor/autoload.php'); date_default_timezone_set($saved_timezone); -// logger('vobject: ' . print_r($ical,true)); - return true; - -// require_once('library/ical.php'); - $ical = new ICal($f); - if($ical) { - $events = $ical->events(); - if($events) { - foreach($events as $ev) { - logger('event parsed: ' . print_r($ev,true), LOGGER_ALL); - event_import_ical($ev,$uid); - } - } + if($ical) return true; - } return false; } -- cgit v1.2.3