aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/items.php6
-rw-r--r--include/zot.php77
-rw-r--r--version.inc2
3 files changed, 72 insertions, 13 deletions
diff --git a/include/items.php b/include/items.php
index 28b19caad..e1ca03fbb 100755
--- a/include/items.php
+++ b/include/items.php
@@ -656,11 +656,11 @@ function encode_item_flags($item) {
// ITEM_DELETED is handled in encode_item directly so we don't need to handle it here.
$ret = array();
- if($item['flags'] & ITEM_THREAD_TOP)
+ if($item['item_flags'] & ITEM_THREAD_TOP)
$ret[] = 'thread_parent';
- if($item['flags'] & ITEM_NSFW)
+ if($item['item_flags'] & ITEM_NSFW)
$ret[] = 'nsfw';
- if($item['flags'] & ITEM_PRIVATE)
+ if($item['item_flags'] & ITEM_PRIVATE)
$ret[] = 'private';
return $ret;
diff --git a/include/zot.php b/include/zot.php
index 1924f3b23..93c63be28 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -604,20 +604,23 @@ function zot_fetch($arr) {
function zot_import($arr) {
logger('zot_import: ' . print_r($arr,true), LOGGER_DATA);
- logger('zot_import: data' . print_r($data,true), LOGGER_DATA);
$data = json_decode($arr['body'],true);
if(array_key_exists('iv',$data)) {
$data = json_decode(aes_unencapsulate($data,get_config('system','prvkey')),true);
}
+ logger('zot_import: data' . print_r($data,true), LOGGER_DATA);
+
$incoming = $data['pickup'];
if(is_array($incoming)) {
foreach($incoming as $i) {
-
+ $i['notify'] = json_decode($i['notify'],true);
+ $i['message'] = json_decode($i['message'],true);
$deliveries = null;
- if($i['notify'] && $i['notify']['recipients']) {
+ if($i['notify'] && array_key_exists('recipients',$i['notify']) && count($i['notify']['recipients'])) {
+ logger('specific recipients');
$recip_arr = array();
foreach($i['notify']['recipients'] as $recip) {
$recip_arr[] = array('hash' => base64url_encode(hash('whirlpool',$recip['guid'] . $recip['guid_sig'], true)));
@@ -625,7 +628,7 @@ function zot_import($arr) {
stringify_array_elms($recip_arr);
$recips = ids_to_querystr($recip_arr,'hash');
- $r = q("select * from channel where channel_hash in ( " . $recips . " ) ");
+ $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) ");
if(! $r)
continue;
@@ -636,17 +639,24 @@ function zot_import($arr) {
}
else {
+ logger('public post');
// Public post. look for any site members who are accepting posts from this sender
-
-
-
+ $deliveries = public_recips($i);
}
if(! $deliveries)
- continue;
+ continue;
+
if($i['message']) {
if($i['message']['type'] === 'activity') {
- // process the message
+ $arr = get_item_elements($i);
+
+ logger('Activity received: ' . print_r($arr,true));
+ logger('Activity recipients: ' . print_r($deliveries,true));
+
+
+ // process the message
+
}
elseif($i['message']['type'] === 'mail') {
@@ -655,3 +665,52 @@ function zot_import($arr) {
}
}
}
+
+
+
+
+function public_recips($msg) {
+
+ logger('public_recips: ' . print_r($msg,true));
+
+ if($msg['message']['type'] === 'activity') {
+ if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
+ $col = 'channel_w_stream';
+ $field = PERMS_W_STREAM;
+ }
+ else {
+ $col = 'channel_w_comment';
+ $field = PERMS_W_COMMENT;
+ }
+ }
+ elseif($msg['message']['type'] === 'mail') {
+ $col = 'channel_w_mail';
+ $field = PERMS_W_MAIL;
+ }
+
+ if(! $col)
+ return NULL;
+
+ if($msg['notify']['sender']['url'] === z_root())
+ $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) ";
+ else
+ $sql = " where ( " . $col . " & " . PERMS_NETWORK . " ) " ;
+
+ $r = q("select channel_hash as hash from channel " . $sql );
+
+ if(! $r)
+ $r = array();
+
+ $x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id where abook_xchan = '%s'
+ and ( " . $col . " & " . PERMS_SPECIFIC . " ) and ( abook_my_perms & " . $field . " ) ",
+ dbesc(base64url_encode(hash('whirlpool',$msg['notify']['sender']['guid'] . $msg['notify']['sender']['guid_sig'], true)))
+ );
+
+ if(! $x)
+ $x = array();
+
+ $r = array_merge($r,$x);
+
+
+ return $r;
+} \ No newline at end of file
diff --git a/version.inc b/version.inc
index 60df03c69..5a0d41bf5 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-11-25.150
+2012-11-26.151