diff options
-rw-r--r-- | include/conversation.php | 2 | ||||
-rwxr-xr-x | include/diaspora.php | 91 | ||||
-rwxr-xr-x | include/items.php | 257 | ||||
-rw-r--r-- | include/network.php | 244 | ||||
-rw-r--r-- | mod/lockview.php | 12 | ||||
-rw-r--r-- | view/nl/messages.po | 4 | ||||
-rw-r--r-- | view/nl/strings.php | 2 |
7 files changed, 373 insertions, 239 deletions
diff --git a/include/conversation.php b/include/conversation.php index 836bd1b24..daf1c723f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -944,7 +944,7 @@ function item_photo_menu($item){ t("View Profile") => $profile_link, t("View Photos") => $photos_link, t("Matrix Activity") => $posts_link, - t("Follow") => $follow_url, + t("Connect") => $follow_url, t("Edit Contact") => $contact_url, t("Send PM") => $pm_url, t("Poke") => $poke_link diff --git a/include/diaspora.php b/include/diaspora.php index 02d479d95..dda552536 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -140,85 +140,30 @@ function find_diaspora_person_by_handle($handle) { $endlessloop = 0; $maxloops = 10; - do { - $r = q("select * from xchan where xchan_addr = '%s' limit 1", - dbesc($handle) - ); - if($r) { - $person = $r[0]; - logger('find_diaspora_person_by handle: in cache ' . print_r($r,true), LOGGER_DEBUG); + + $r = q("select * from xchan where xchan_addr = '%s' limit 1", + dbesc($handle) + ); + if($r) { + $person = $r[0]; + logger('find_diaspora_person_by handle: in cache ' . print_r($r,true), LOGGER_DATA); // update record occasionally so it doesn't get stale - $d = strtotime($person['updated'] . ' +00:00'); - if($d < strtotime('now - 14 days')) - $update = true; - } +// $d = strtotime($person['updated'] . ' +00:00'); +// if($d < strtotime('now - 14 days')) +// $update = true; + } + if((! $person) || ($update)) { - // FETCHING PERSON INFORMATION FROM REMOTE SERVER - // - // If the person isn't in our 'fcontact' table, or if he/she is but - // his/her information hasn't been updated for more than 14 days, then - // we want to fetch the person's information from the remote server. - // - // Note that $person isn't changed by this block of code unless the - // person's information has been successfully fetched from the remote - // server. So if $person was 'false' to begin with (because he/she wasn't - // in the local cache), it'll stay false, and if $person held the local - // cache information to begin with, it'll keep that information. That way - // if there's a problem with the remote fetch, we can at least use our - // cached information--it's better than nothing. - -//fixme!!! - - if((! $person) || ($update)) { - // Lock the function to prevent race conditions if multiple items - // come in at the same time from a person who doesn't exist in - // fcontact - // - // Don't loop forever. On the last loop, try to create the contact - // whether the function is locked or not. Maybe the locking thread - // has died or something. At any rate, a duplicate in 'fcontact' - // is a much smaller problem than a deadlocked thread -// $got_lock = lock_function('find_diaspora_person_by_handle', false); - if(($endlessloop + 1) >= $maxloops) - $got_lock = true; - - if($got_lock) { - logger('find_diaspora_person_by_handle: create or refresh', LOGGER_DEBUG); - require_once('include/Scrape.php'); - $r = probe_url($handle, PROBE_DIASPORA); - - // Note that Friendica contacts can return a "Diaspora person" - // if Diaspora connectivity is enabled on their server - if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) { - add_fcontact($r,$update); - $person = ($r); - } + // try webfinger. Make sure to distinguish between diaspora, + // redmatrix w/diaspora protocol and friendica w/diaspora protocol. -// unlock_function('find_diaspora_person_by_handle'); - } - else { - logger('find_diaspora_person_by_handle: couldn\'t lock function', LOGGER_DEBUG); -// if(! $person) -// block_on_function_lock('find_diaspora_person_by_handle'); - } - } - } while((! $person) && (! $got_lock) && (++$endlessloop < $maxloops)); + $result = discover_by_webbie($handle); + + + } - // We need to try again if the person wasn't in 'fcontact' but the function was locked. - // The fact that the function was locked may mean that another process was creating the - // person's record. It could also mean another process was creating or updating an unrelated - // person. - // - // At any rate, we need to keep trying until we've either got the person or had a chance to - // try to fetch his/her remote information. But we don't want to block on locking the - // function, because if the other process is creating the record, then when we acquire the lock - // we'll dive right into creating another, duplicate record. We DO want to at least wait - // until the lock is released, so we don't flood the database with requests. - // - // If the person was in the 'fcontact' table, don't try again. It's not worth the time, since - // we do have some information for the person return $person; } diff --git a/include/items.php b/include/items.php index 05ff1b078..30a685ed3 100755 --- a/include/items.php +++ b/include/items.php @@ -1233,13 +1233,14 @@ function get_atom_elements($feed,$item) { $author = $item->get_author(); if($author) { - $res['author-name'] = unxmlify($author->get_name()); - $res['author-link'] = unxmlify($author->get_link()); + $res['author_name'] = unxmlify($author->get_name()); + $res['author_link'] = unxmlify($author->get_link()); } else { - $res['author-name'] = unxmlify($feed->get_title()); - $res['author-link'] = unxmlify($feed->get_permalink()); + $res['author_name'] = unxmlify($feed->get_title()); + $res['author_link'] = unxmlify($feed->get_permalink()); } + $res['mid'] = unxmlify($item->get_id()); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); @@ -1264,9 +1265,9 @@ function get_atom_elements($feed,$item) { if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach($base as $link) { - if(!x($res, 'author-avatar') || !$res['author-avatar']) { + if(!x($res, 'author_photo') || !$res['author_photo']) { if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') - $res['author-avatar'] = unxmlify($link['attribs']['']['href']); + $res['author_photo'] = unxmlify($link['attribs']['']['href']); } } } @@ -1277,11 +1278,11 @@ function get_atom_elements($feed,$item) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { foreach($base as $link) { - if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link'])) - $res['author-link'] = unxmlify($link['attribs']['']['href']); - if(!x($res, 'author-avatar') || !$res['author-avatar']) { + if($link['attribs']['']['rel'] === 'alternate' && (! $res['author_link'])) + $res['author_link'] = unxmlify($link['attribs']['']['href']); + if(!x($res, 'author_photo') || !$res['author_photo']) { if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') - $res['author-avatar'] = unxmlify($link['attribs']['']['href']); + $res['author_photo'] = unxmlify($link['attribs']['']['href']); } } } @@ -1289,16 +1290,16 @@ function get_atom_elements($feed,$item) { // No photo/profile-link on the item - look at the feed level - if((! (x($res,'author-link'))) || (! (x($res,'author-avatar')))) { + if((! (x($res,'author_link'))) || (! (x($res,'author_photo')))) { $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'author'); if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach($base as $link) { - if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link'])) - $res['author-link'] = unxmlify($link['attribs']['']['href']); - if(! $res['author-avatar']) { + if($link['attribs']['']['rel'] === 'alternate' && (! $res['author_link'])) + $res['author_link'] = unxmlify($link['attribs']['']['href']); + if(! $res['author_photo']) { if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') - $res['author-avatar'] = unxmlify($link['attribs']['']['href']); + $res['author_photo'] = unxmlify($link['attribs']['']['href']); } } } @@ -1310,11 +1311,11 @@ function get_atom_elements($feed,$item) { if($base && count($base)) { foreach($base as $link) { - if($link['attribs']['']['rel'] === 'alternate' && (! $res['author-link'])) - $res['author-link'] = unxmlify($link['attribs']['']['href']); - if(! (x($res,'author-avatar'))) { + if($link['attribs']['']['rel'] === 'alternate' && (! $res['author_link'])) + $res['author_link'] = unxmlify($link['attribs']['']['href']); + if(! (x($res,'author_photo'))) { if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') - $res['author-avatar'] = unxmlify($link['attribs']['']['href']); + $res['author_photo'] = unxmlify($link['attribs']['']['href']); } } } @@ -1378,9 +1379,9 @@ function get_atom_elements($feed,$item) { $private = $item->get_item_tags(NAMESPACE_DFRN,'private'); if($private && intval($private[0]['data']) > 0) - $res['private'] = intval($private[0]['data']); + $res['item_private'] = ((intval($private[0]['data'])) ? 1 : 0); else - $res['private'] = 0; + $res['item_private'] = 0; $rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location'); if($rawlocation) @@ -1419,21 +1420,21 @@ function get_atom_elements($feed,$item) { $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) - $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); + $res['owner_name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); elseif($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']) - $res['owner-name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']); + $res['owner_name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']) - $res['owner-link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']); + $res['owner_link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']); elseif($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']) - $res['owner-link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']); + $res['owner_link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) { $base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; foreach($base as $link) { - if(!x($res, 'owner-avatar') || !$res['owner-avatar']) { + if(!x($res, 'owner_photo') || !$res['owner_photo']) { if($link['attribs']['']['rel'] === 'photo' || $link['attribs']['']['rel'] === 'avatar') - $res['owner-avatar'] = unxmlify($link['attribs']['']['href']); + $res['owner_photo'] = unxmlify($link['attribs']['']['href']); } } } @@ -1488,6 +1489,7 @@ function get_atom_elements($feed,$item) { $attach = $item->get_enclosures(); if($attach) { + $res['attach'] = array(); $att_arr = array(); foreach($attach as $att) { $len = intval($att->get_length()); @@ -1503,33 +1505,32 @@ function get_atom_elements($feed,$item) { $title = ' '; if(! $type) $type = 'application/octet-stream'; - - $att_arr[] = '[attach]href="' . $link . '" length="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]'; } - $res['attach'] = implode(',', $att_arr); + $res['attach'][] = array('href' => $link, 'length' => $len, 'type' => $type, 'title' => $title ); } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); if($rawobj) { - $res['object'] = '<object>' . "\n"; + $obj = array(); + $child = $rawobj[0]['child']; if($child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']) { $res['obj_type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; - $res['object'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data'] . '</type>' . "\n"; + $obj['type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; } if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) - $res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; + $obj['id'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']; if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) - $res['object'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; + $obj['link'] = encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']); if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) - $res['object'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n"; + $obj['title'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']; if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if(! $body) $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events - $res['object'] .= '<orig>' . xmlify($body) . '</orig>' . "\n"; + $obj['orig'] = xmlify($body); if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { $body = purify_html($body); @@ -1537,48 +1538,52 @@ function get_atom_elements($feed,$item) { } - $res['object'] .= '<content>' . $body . '</content>' . "\n"; + $obj['content'] = $body; } - $res['object'] .= '</object>' . "\n"; + $res['object'] = $obj; } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'target'); if($rawobj) { - $res['target'] = '<target>' . "\n"; + $obj = array(); + $child = $rawobj[0]['child']; if($child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']) { - $res['target'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data'] . '</type>' . "\n"; + $res['tgt_type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; + $obj['type'] = $child[NAMESPACE_ACTIVITY]['obj_type'][0]['data']; } if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']) - $res['target'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n"; + $obj['id'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data']; if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) - $res['target'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n"; - if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) - $res['target'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n"; - if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { + $obj['link'] = encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']); + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']) + $obj['title'] = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data']; + if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) { $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']; if(! $body) $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data']; // preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events - $res['target'] .= '<orig>' . xmlify($body) . '</orig>' . "\n"; + $obj['orig'] = xmlify($body); if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { $body = purify_html($body); $body = html2bbcode($body); + } - $res['target'] .= '<content>' . $body . '</content>' . "\n"; + $obj['content'] = $body; } - $res['target'] .= '</target>' . "\n"; + $res['target'] = $obj; } // This is some experimental stuff. By now retweets are shown with "RT:" // But: There is data so that the message could be shown similar to native retweets // There is some better way to parse this array - but it didn't worked for me. +/* $child = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["entry"][0]["child"]["http://activitystrea.ms/spec/1.0/"][object][0]["child"]; if (is_array($child)) { $message = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["content"][0]["data"]; @@ -1601,6 +1606,8 @@ function get_atom_elements($feed,$item) { } } +*/ + $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); @@ -1613,6 +1620,10 @@ function encode_rel_links($links) { $o = ''; if(! ((is_array($links)) && (count($links)))) return $o; + +//fixme + return ''; + foreach($links as $link) { $o .= '<link '; if($link['attribs']['']['rel']) @@ -2342,6 +2353,10 @@ function tag_deliver($uid,$item_id) { $mention = false; + /** + * Fetch stuff we need - a channel and an item + */ + $u = q("select * from channel where channel_id = %d limit 1", intval($uid) ); @@ -2367,6 +2382,10 @@ function tag_deliver($uid,$item_id) { } + /** + * Seems like a good place to plug in a poke notification. + */ + if (stristr($item['verb'],ACTIVITY_POKE)) { $poke_notify = true; @@ -2395,6 +2414,10 @@ function tag_deliver($uid,$item_id) { } } + /** + * Do community tagging + */ + if($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) { // We received a community tag activity for a post. @@ -2435,6 +2458,11 @@ function tag_deliver($uid,$item_id) { logger('tag_deliver: tag permission denied for ' . $u[0]['channel_address']); } + /** + * A "union" is a message which our channel has sourced from another channel. + * This sets up a second delivery chain just like forum tags do. + * Find out if this is a source-able post. + */ $union = check_item_source($uid,$item); if($union) @@ -2462,9 +2490,12 @@ function tag_deliver($uid,$item_id) { $private = (($u[0]['channel_allow_cid'] || $u[0]['channel_allow_gid'] || $u[0]['channel_deny_cid'] || $u[0]['channel_deny_gid']) ? 1 : 0); -//FIXME - add check for public_policy + $new_public_policy = map_scope($u[0]['channel_r_stream'],true); - $flag_bits = ITEM_WALL|ITEM_ORIGIN; + if((! $private) && $new_public_policy) + $private = 1; + + $flag_bits = $item['item_flags'] | ITEM_WALL|ITEM_ORIGIN; // maintain the original source, which will be the original item owner and was stored in source_xchan // when we created the delivery fork @@ -2474,8 +2505,28 @@ function tag_deliver($uid,$item_id) { intval($item_id) ); - $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', - deny_cid = '%s', deny_gid = '%s', item_private = %d where id = %d limit 1", + $title = $item['title']; + $body = $item['body']; + + if($private) { + if(!($flag_bits & ITEM_OBSCURED)) { + $key = get_config('system','pubkey'); + $flag_bits = $flag_bits|ITEM_OBSCURED; + $title = json_encode(aes_encapsulate($title,$key)); + $body = json_encode(aes_encapsulate($body,$key)); + } + } + else { + if($flag_bits & ITEM_OBSCURED) { + $key = get_config('system','prvkey'); + $flag_bits = $flag_bits ^ ITEM_OBSCURED; + $title = json_encode(aes_unencapsulate($title,$key)); + $body = json_encode(aes_unencapsulate($body,$key)); + } + } + + $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', + deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s' where id = %d limit 1", intval($flag_bits), dbesc($u[0]['channel_hash']), dbesc($u[0]['channel_allow_cid']), @@ -2483,6 +2534,10 @@ function tag_deliver($uid,$item_id) { dbesc($u[0]['channel_deny_cid']), dbesc($u[0]['channel_deny_gid']), intval($private), + dbesc($new_public_policy), + dbesc(map_scope($u[0]['channel_w_comment'])), + dbesc($title), + dbesc($body), intval($item_id) ); if($r) @@ -2492,6 +2547,12 @@ function tag_deliver($uid,$item_id) { } } + + /** + * Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery + */ + + $terms = get_terms_oftype($item['term'],TERM_MENTION); if($terms) @@ -2553,7 +2614,9 @@ function tag_deliver($uid,$item_id) { $arr = array('channel_id' => $uid, 'item' => $item, 'body' => $body); call_hooks('tagged',$arr); - // Valid tag. Send a notification + /** + * Kill two birds with one stone. As long as we're here, send a mention notification. + */ require_once('include/enotify.php'); notification(array( @@ -2597,6 +2660,10 @@ function tag_deliver($uid,$item_id) { return; } + /** + * At this point we're committed to setting up a second delivery chain. We just have to mangle some bits first. + */ + logger('tag_deliver: creating second delivery chain.'); // now change this copy of the post to a forum head message and deliver to all the tgroup members @@ -2604,9 +2671,12 @@ function tag_deliver($uid,$item_id) { $private = (($u[0]['channel_allow_cid'] || $u[0]['channel_allow_gid'] || $u[0]['channel_deny_cid'] || $u[0]['channel_deny_gid']) ? 1 : 0); -// FIXME set public_policy and recheck private + $new_public_policy = map_scope($u[0]['channel_r_stream'],true); + + if((! $private) && $new_public_policy) + $private = 1; - $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK; + $flag_bits = $item['item_flags'] | ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK; // preserve the source @@ -2614,8 +2684,30 @@ function tag_deliver($uid,$item_id) { intval($item_id) ); - $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', - deny_cid = '%s', deny_gid = '%s', item_private = %d where id = %d limit 1", + // make sure encryption matches the new scope + + $title = $item['title']; + $body = $item['body']; + + if($private) { + if(!($flag_bits & ITEM_OBSCURED)) { + $key = get_config('system','pubkey'); + $flag_bits = $flag_bits|ITEM_OBSCURED; + $title = json_encode(aes_encapsulate($title,$key)); + $body = json_encode(aes_encapsulate($body,$key)); + } + } + else { + if($flag_bits & ITEM_OBSCURED) { + $key = get_config('system','prvkey'); + $flag_bits = $flag_bits ^ ITEM_OBSCURED; + $title = json_encode(aes_unencapsulate($title,$key)); + $body = json_encode(aes_unencapsulate($body,$key)); + } + } + + $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', + deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s' where id = %d limit 1", intval($flag_bits), dbesc($u[0]['channel_hash']), dbesc($u[0]['channel_allow_cid']), @@ -2623,6 +2715,10 @@ function tag_deliver($uid,$item_id) { dbesc($u[0]['channel_deny_cid']), dbesc($u[0]['channel_deny_gid']), intval($private), + dbesc($new_public_policy), + dbesc(map_scope($u[0]['channel_w_comment'])), + dbesc($title), + dbesc($body), intval($item_id) ); if($r) @@ -2632,6 +2728,16 @@ function tag_deliver($uid,$item_id) { } +/** + * @function tgroup_check($uid,$item) + * + * This function is called pre-deliver to see if a post matches the criteria to be tag delivered. + * We don't actually do anything except check that it matches the criteria. + * This is so that the channel with tag_delivery enabled can receive the post even if they turn off + * permissions for the sender to send their stream. tag_deliver() can't be called until the post is actually stored. + * By then it would be too late to reject it. + */ + function tgroup_check($uid,$item) { @@ -2899,7 +3005,7 @@ function mail_store($arr) { * recursion. */ -function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) { +function consume_feed($xml,$importer,&$contact,$pass = 0) { require_once('library/simplepie/simplepie.inc'); @@ -2943,8 +3049,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) else $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); } + + if($deleted && is_array($contact)) { -/* $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` +/* + $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` WHERE `mid` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", dbesc($mid), intval($importer['channel_id']), @@ -3021,14 +3130,15 @@ logger('consume_feed: processing ' . $item_id); $item_id = $item->get_id(); $datarray = get_atom_elements($feed,$item); +/* if((! x($datarray,'author-name')) && ($contact['network'] != NETWORK_DFRN)) $datarray['author-name'] = $contact['name']; if((! x($datarray,'author-link')) && ($contact['network'] != NETWORK_DFRN)) $datarray['author-link'] = $contact['url']; if((! x($datarray,'author-avatar')) && ($contact['network'] != NETWORK_DFRN)) $datarray['author-avatar'] = $contact['thumb']; - - if((! x($datarray,'author-name')) || (! x($datarray,'author-link'))) { +*/ + if((! x($datarray,'author_name')) || (! x($datarray,'author_link'))) { logger('consume_feed: no author information! ' . print_r($datarray,true)); continue; } @@ -3063,7 +3173,8 @@ logger('consume_feed: processing ' . $item_id); $datarray['parent_mid'] = $parent_mid; $datarray['uid'] = $importer['channel_id']; - $datarray['contact-id'] = $contact['id']; +// $datarray['contact-id'] = $contact['id']; + if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; @@ -3250,6 +3361,28 @@ logger('consume_feed: ' . print_r($datarray,true)); } +function handle_feed($uid,$abook_id,$url) { + + require_once('include/Contact.php'); + $channel = channelx_by_n($uid); + if(! $channel) + return; + $x = q("select * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d limit 1", + dbesc($abook_id), + intval($uid) + ); + + $recurse = 0; + $z = z_fetch_url($url,false,$recurse,array('novalidate' => true)); + +logger('handle_feed:' . print_r($z,true)); + + if($z['success']) { + consume_feed($z['body'],$channel,$x[0],0); + consume_feed($z['body'],$channel,$x[0],1); + } +} + function atom_author($tag,$name,$uri,$h,$w,$type,$photo) { $o = ''; diff --git a/include/network.php b/include/network.php index 66bba5b38..1a974a681 100644 --- a/include/network.php +++ b/include/network.php @@ -337,101 +337,6 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) { } } -// Given an email style address, perform webfinger lookup and -// return the resulting DFRN profile URL, or if no DFRN profile URL -// is located, returns an OStatus subscription template (prefixed -// with the string 'stat:' to identify it as on OStatus template). -// If this isn't an email style address just return $s. -// Return an empty string if email-style addresses but webfinger fails, -// or if the resultant personal XRD doesn't contain a supported -// subscription/friend-request attribute. - -// amended 7/9/2011 to return an hcard which could save potentially loading -// a lengthy content page to scrape dfrn attributes - - -function webfinger_dfrn($s,&$hcard) { - if(! strstr($s,'@')) { - return $s; - } - $profile_link = ''; - - $links = webfinger($s); - logger('webfinger_dfrn: ' . $s . ':' . print_r($links,true), LOGGER_DATA); - if(count($links)) { - foreach($links as $link) { - if($link['@attributes']['rel'] === NAMESPACE_DFRN) - $profile_link = $link['@attributes']['href']; - if($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB) - $profile_link = 'stat:' . $link['@attributes']['template']; - if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') - $hcard = $link['@attributes']['href']; - } - } - return $profile_link; -} - -// Given an email style address, perform webfinger lookup and -// return the array of link attributes from the personal XRD file. -// On error/failure return an empty array. - - - -function webfinger($s, $debug = false) { - $host = ''; - if(strstr($s,'@')) { - $host = substr($s,strpos($s,'@') + 1); - } - if(strlen($host)) { - $tpl = fetch_lrdd_template($host); - logger('webfinger: lrdd template: ' . $tpl); - if(strlen($tpl)) { - $pxrd = str_replace('{uri}', urlencode('acct:' . $s), $tpl); - logger('webfinger: pxrd: ' . $pxrd); - $links = fetch_xrd_links($pxrd); - if(! count($links)) { - // try with double slashes - $pxrd = str_replace('{uri}', urlencode('acct://' . $s), $tpl); - logger('webfinger: pxrd: ' . $pxrd); - $links = fetch_xrd_links($pxrd); - } - return $links; - } - } - return array(); -} - - - - -// Given a host name, locate the LRDD template from that -// host. Returns the LRDD template or an empty string on -// error/failure. - - -function fetch_lrdd_template($host) { - $tpl = ''; - - $url1 = 'https://' . $host . '/.well-known/host-meta' ; - $url2 = 'http://' . $host . '/.well-known/host-meta' ; - $links = fetch_xrd_links($url1); - logger('fetch_lrdd_template from: ' . $url1); - logger('template (https): ' . print_r($links,true)); - if(! count($links)) { - logger('fetch_lrdd_template from: ' . $url2); - $links = fetch_xrd_links($url2); - logger('template (http): ' . print_r($links,true)); - } - if(count($links)) { - foreach($links as $link) - if($link['@attributes']['rel'] && $link['@attributes']['rel'] === 'lrdd') - $tpl = $link['@attributes']['template']; - } - if(! strpos($tpl,'{uri}')) - $tpl = ''; - return $tpl; -} - // Take a URL from the wild, prepend http:// if necessary // and check DNS to see if it's real (or check if is a valid IP address) // return true if it's OK, false if something is wrong with it @@ -912,3 +817,152 @@ function email_send($addr, $subject, $headers, $item) { logger('notifier: email delivery to ' . $addr); mail($addr, $subject, $body, $headers); } + + +function discover_by_webbie($webbie) { + + $x = webfinger_rfc7033($webbie); + if($x && array_key_exists('links',$x) && $x['links']) { + foreach($x['links'] as $link) { + if(array_key_exists('rel',$link) && $link['rel'] == 'http://purl.org/zot/protocol') { + logger('discover_by_webbie: zot found for ' . $webbie); + $z = z_fetch_url($link['href']); + if($z['success']) { + $j = json_decode($z['body'],true); + $i = import_xchan($j); + return true; + } + } + } + } + + $x = old_webfinger($webbie); + if($x) { + logger('old_webfinger: ' . print_r($x,true)); + } +} + + +function webfinger_rfc7033($webbie) { + + + if(! strpos($webbie,'@')) + return false; + $lhs = substr($webbie,0,strpos($webbie,'@')); + $rhs = substr($webbie,strpos($webbie,'@')+1); + + $resource = 'acct:' . $webbie; + + $s = z_fetch_url('https://' . $rhs . '/.well-known/webfinger?resource=' . $resource); + + if($s['success']) + $j = json_decode($s['body'],true); + else + return false; + return($j); +} + + +function old_webfinger($webbie) { + + $host = ''; + if(strstr($webbie,'@')) + $host = substr($webbie,strpos($webbie,'@') + 1); + + if(strlen($host)) { + $tpl = fetch_lrdd_template($host); + logger('old_webfinger: lrdd template: ' . $tpl,LOGGER_DATA); + if(strlen($tpl)) { + $pxrd = str_replace('{uri}', urlencode('acct:' . $webbie), $tpl); + logger('old_webfinger: pxrd: ' . $pxrd,LOGGER_DATA); + $links = fetch_xrd_links($pxrd); + if(! count($links)) { + // try with double slashes + $pxrd = str_replace('{uri}', urlencode('acct://' . $webbie), $tpl); + logger('old_webfinger: pxrd: ' . $pxrd,LOGGER_DATA); + $links = fetch_xrd_links($pxrd); + } + return $links; + } + } + return array(); +} + + +function fetch_lrdd_template($host) { + $tpl = ''; + + $url1 = 'https://' . $host . '/.well-known/host-meta' ; + $url2 = 'http://' . $host . '/.well-known/host-meta' ; + $links = fetch_xrd_links($url1); + logger('fetch_lrdd_template from: ' . $url1, LOGGER_DEBUG); + logger('template (https): ' . print_r($links,true),LOGGER_DEBUG); + if(! count($links)) { + logger('fetch_lrdd_template from: ' . $url2); + $links = fetch_xrd_links($url2); + logger('template (http): ' . print_r($links,true),LOGGER_DEBUG); + } + if(count($links)) { + foreach($links as $link) + if($link['@attributes']['rel'] && $link['@attributes']['rel'] === 'lrdd' && (!$link['@attributes']['type'] || $link['@attributes']['type'] === 'application/xrd+xml')) + $tpl = $link['@attributes']['template']; + } + if(! strpos($tpl,'{uri}')) + $tpl = ''; + return $tpl; + +} + + +function fetch_xrd_links($url) { + +logger('fetch_xrd_links: ' . $url); + + $redirects = 0; + $x = z_fetch_url($url,false,$redirects,array('timeout' => 20)); + + if(! $x['success']) + return array(); + + $xml = $x['body']; + logger('fetch_xrd_links: ' . $xml, LOGGER_DATA); + + if ((! $xml) || (! stristr($xml,'<xrd'))) + return array(); + + // fix diaspora's bad xml + $xml = str_replace(array('href="','"/>'),array('href="','"/>'),$xml); + + $h = parse_xml_string($xml); + if(! $h) + return array(); + + $arr = convert_xml_element_to_array($h); + + $links = array(); + + if(isset($arr['xrd']['link'])) { + $link = $arr['xrd']['link']; + + if(! isset($link[0])) + $links = array($link); + else + $links = $link; + } + if(isset($arr['xrd']['alias'])) { + $alias = $arr['xrd']['alias']; + if(! isset($alias[0])) + $aliases = array($alias); + else + $aliases = $alias; + if(is_array($aliases) && count($aliases)) { + foreach($aliases as $alias) { + $links[]['@attributes'] = array('rel' => 'alias' , 'href' => $alias); + } + } + } + + logger('fetch_xrd_links: ' . print_r($links,true), LOGGER_DATA); + + return $links; +}
\ No newline at end of file diff --git a/mod/lockview.php b/mod/lockview.php index 7d39f9e2f..6673ae709 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -33,7 +33,13 @@ function lockview_content(&$a) { if(($item['item_private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid'])) && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) { - echo '<li>' . translate_scope($item['public_policy']) . '</li>'; + + // if the post is private, but public_policy is blank ("visible to the internet"), and there aren't any + // specific recipients, we're the recipient of a post with "bcc" or targeted recipients; so we'll just show it + // as unknown specific recipients. The sender will have the visibility list and will fall through to the + // next section. + + echo '<li>' . translate_scope((! $item['public_policy']) ? PERMS_SPECIFIC : $item['public_policy']) . '</li>'; killme(); } @@ -78,9 +84,5 @@ function lockview_content(&$a) { echo $o . implode($l); killme(); - if(array_key_exists('public_policy',$item) && $item['public_policy']) { - echo '<li>' . translate_scope($item['public_policy']) . '</li>'; - killme(); - } } diff --git a/view/nl/messages.po b/view/nl/messages.po index 48ed857b6..451b492a7 100644 --- a/view/nl/messages.po +++ b/view/nl/messages.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: Red Matrix\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-08-15 00:03-0700\n" -"PO-Revision-Date: 2014-08-19 20:17+0000\n" +"PO-Revision-Date: 2014-08-19 21:46+0000\n" "Last-Translator: jeroenpraat <>\n" "Language-Team: Dutch (http://www.transifex.com/projects/p/red-matrix/language/nl/)\n" "MIME-Version: 1.0\n" @@ -49,7 +49,7 @@ msgstr "foto" #: ../../include/conversation.php:148 ../../mod/subthread.php:72 #: ../../mod/subthread.php:174 ../../mod/tagger.php:53 ../../mod/like.php:294 msgid "status" -msgstr "status" +msgstr "bericht" #: ../../include/diaspora.php:1926 ../../include/conversation.php:164 #: ../../mod/like.php:331 diff --git a/view/nl/strings.php b/view/nl/strings.php index 472a69829..7be347e53 100644 --- a/view/nl/strings.php +++ b/view/nl/strings.php @@ -10,7 +10,7 @@ $a->strings["Profile Photos"] = "Profielfoto's"; $a->strings["%1\$s is now friends with %2\$s"] = "%1\$s is nu bevriend met %2\$s"; $a->strings["Sharing notification from Diaspora network"] = "Notificatie delen vanuit het Diaspora-netwerk"; $a->strings["photo"] = "foto"; -$a->strings["status"] = "status"; +$a->strings["status"] = "bericht"; $a->strings["%1\$s likes %2\$s's %3\$s"] = "%1\$s vindt %3\$s van %2\$s leuk"; $a->strings["Attachments:"] = "Bijlagen:"; $a->strings["Embedded content"] = "Ingesloten inhoud"; |