From bf190be5b42378e3a9c122a5ff2311691b4814fe Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 23 Aug 2015 13:27:34 -0700 Subject: issues encountered with hubzilla DB changes, zot_refresh and item_drop and hub sync --- include/items.php | 2 +- include/zot.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 0079e0e55..9fefa699a 100755 --- a/include/items.php +++ b/include/items.php @@ -4366,7 +4366,7 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { ); } else { - $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where if = %d", + $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']) diff --git a/include/zot.php b/include/zot.php index 17330838b..178b8fe57 100644 --- a/include/zot.php +++ b/include/zot.php @@ -294,12 +294,12 @@ function zot_refresh($them, $channel = null, $force = false) { if ($them['hubloc_url']) { $url = $them['hubloc_url']; } else { - $r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'", + $r = q("select hubloc_url, hubloc_primary from hubloc where hubloc_hash = '%s'", dbesc($them['xchan_hash']) ); if ($r) { foreach ($r as $rr) { - if ($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) { + if (intval($rr['hubloc_primary'])) { $url = $rr['hubloc_url']; break; } @@ -2207,7 +2207,7 @@ function sync_locations($sender, $arr, $absolute = false) { dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); - $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; + $r[0]['hubloc_primary'] = intval($location['primary']); hubloc_change_primary($r[0]); $what .= 'primary_hub '; $changed = true; -- cgit v1.2.3 From 8cd583fd8ca1c81a13a08385a2cd6921395c0527 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 23 Aug 2015 17:36:00 -0700 Subject: sync abook flags in memory after altering them --- include/Contact.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 6b5f9388c..008574d8f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -174,9 +174,6 @@ function abook_toggle_flag($abook,$flag) { ); } - $a = get_app(); - if($a->data['abook']) - $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; return $r; } -- cgit v1.2.3 From b1f091e4d7de4467495bb1bde0b0054f5f10403d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 23 Aug 2015 17:40:47 -0700 Subject: issues with abook sync between hubzilla and red --- include/zot.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 19bacfa4f..76f73934d 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2930,7 +2930,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $total_feeds ++; } - $disallowed = array('abook_id','abook_account','abook_channel'); + $disallowed = array('abook_id','abook_account','abook_channel','abook_blocked','abook_ignored','abook_hidden','abook_archived','abook_pending','abook_unconnected','abook_self','abook_feed'); foreach($arr['abook'] as $abook) { @@ -3029,7 +3029,6 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($clean as $k => $v) { if($k == 'abook_dob') $v = dbescdate($v); - $r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v) . "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id'])); } -- cgit v1.2.3 From a67213627c3124fc55f2545d138d368c4dea0fbe Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 23 Aug 2015 18:48:33 -0700 Subject: provide a comment_policy of "network: diaspora" to handle their special case public-posts-are-commentable-by-anybody permission without breaking any other permissions. --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9fefa699a..2701c3fa2 100755 --- a/include/items.php +++ b/include/items.php @@ -272,6 +272,8 @@ function can_comment_on_post($observer_xchan, $item) { } if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'red')) return true; + if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'diaspora')) + return true; if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],get_app()->get_hostname())) return true; -- cgit v1.2.3 From 250d286f1dd8ee9ca244df25946e56b09ee5ff18 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 24 Aug 2015 01:28:13 -0700 Subject: remove orphan mod_connections editing code (now done in mod/connedit) --- include/Contact.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 035e83a82..a27a8eca9 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -149,9 +149,6 @@ function abook_toggle_flag($abook,$flag) { ); } - $a = get_app(); - if($a->data['abook']) - $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; return $r; } -- cgit v1.2.3 From d256e8e9f28aa3efcd0a5ac7f7326ba24367ea31 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 24 Aug 2015 01:46:54 -0700 Subject: edited event showing bad signature and null_date for edit timestamp --- include/event.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index c468420c0..6670bc53b 100644 --- a/include/event.php +++ b/include/event.php @@ -778,7 +778,12 @@ function event_store_item($arr, $event) { $private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0); - q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d", + // @FIXME can only update sig if we have the author's channel on this site + // Until fixed, set it to nothing so it won't give us signature errors + + $sig = ''; + + q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d", dbesc($arr['summary']), dbesc($prefix . format_event_bbcode($arr)), dbesc($object), @@ -787,6 +792,7 @@ function event_store_item($arr, $event) { dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), dbesc($arr['edited']), + dbesc($sig), intval($r[0]['item_flags']), intval($private), dbesc(ACTIVITY_OBJ_EVENT), -- cgit v1.2.3 From 0edac8810b702ee4a8b8aeef18003d5549c1ac0d Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 24 Aug 2015 16:05:51 -0700 Subject: don't try to optimise the session table. Just let it fragment and let the DB worry about it. --- include/session.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/session.php b/include/session.php index 31b3f0614..92004bc18 100644 --- a/include/session.php +++ b/include/session.php @@ -98,9 +98,6 @@ function ref_session_destroy ($id) { function ref_session_gc($expire) { q("DELETE FROM session WHERE expire < %d", dbesc(time())); - if (! get_config('system', 'innodb')) - db_optimizetable('session'); - return true; } -- cgit v1.2.3 From 5fa2aa6d481fe0597044f2e3d4434fc9f4311fe7 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 24 Aug 2015 20:58:12 -0700 Subject: lots of stuff that was needed for successful photo import from red --- include/attach.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++-------- include/photos.php | 21 ++++++++++----- 2 files changed, 81 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 71fad86a8..a23f0f81a 100644 --- a/include/attach.php +++ b/include/attach.php @@ -414,9 +414,19 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $hash = (($arr && $arr['hash']) ? $arr['hash'] : null); $upload_path = (($arr && $arr['directory']) ? $arr['directory'] : ''); - logger('arr: ' . print_r($arr,true)); + $observer = array(); - if(! perm_is_allowed($channel_id,get_observer_hash(), 'write_storage')) { + if($observer_hash) { + $x = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($observer_hash) + ); + if($x) + $observer = $x[0]; + } + + logger('arr: ' . print_r($arr,true)); + + if(! perm_is_allowed($channel_id,$observer_hash, 'write_storage')) { $ret['message'] = t('Permission denied.'); return $ret; } @@ -434,7 +444,13 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { // revise or update must provide $arr['hash'] of the thing to revise/update - if($options !== 'update') { + if($options === 'import') { + $src = $arr['src']; + $filename = $arr['filename']; + $filesize = @filesize($src); + $hash = $arr['resource_id']; + } + elseif($options !== 'update') { if(! x($_FILES,'userfile')) { $ret['message'] = t('No source file.'); return $ret; @@ -480,12 +496,19 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { - + $def_extension = ''; $is_photo = 0; $gis = @getimagesize($src); logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA); if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) { $is_photo = 1; + if($gis[2] === IMAGETYPE_GIF) + $def_extension = '.gif'; + if($gis[2] === IMAGETYPE_JPEG) + $def_extension = '.jpg'; + if($gis[2] === IMAGETYPE_PNG) + $def_extension = '.png'; + } $pathname = ''; @@ -527,7 +550,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $folder_hash = ''; } - if(! $options) { + if((! $options) || ($options === 'import')) { // A freshly uploaded file. Check for duplicate and resolve with the channel's overwrite settings. @@ -544,9 +567,18 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $hash = $x[0]['hash']; } else { + if(strpos($filename,'.') !== false) { + $basename = substr($filename,0,strrpos($filename,'.')); + $ext = substr($filename,strrpos($filename,'.')); + } + else { + $basename = $filename; + $ext = $def_extension; + } + $r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ", - dbesc($filename), - dbesc($filename . '(%)'), + dbesc($basename . $ext), + dbesc($basename . '(%)' . $ext), dbesc($folder_hash) ); @@ -556,7 +588,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { do { $found = false; foreach($r as $rr) { - if($rr['filename'] === $filename . '(' . $x . ')') { + if($rr['filename'] === $basename . '(' . $x . ')' . $ext) { $found = true; break; } @@ -565,8 +597,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $x++; } while($found); - $filename = $filename . '(' . $x . ')'; + $filename = $basename . '(' . $x . ')' . $ext; } + else + $filename = $basename . $ext; } } } @@ -614,7 +648,16 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { if($src) @file_put_contents($os_basepath . $os_relpath,@file_get_contents($src)); - $created = datetime_convert(); + if(array_key_exists('created', $arr)) + $created = $arr['created']; + else + $created = datetime_convert(); + + if(array_key_exists('edited', $arr)) + $edited = $arr['edited']; + else + $edited = $created; + if($options === 'replace') { $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, data = '%s', edited = '%s' where id = %d and uid = %d", @@ -704,7 +747,19 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $args['contact_deny'] = $arr['contact_deny']; if($arr['group_deny']) $args['group_deny'] = $arr['group_deny']; - $p = photo_upload($channel,get_app()->get_observer(),$args); + if(array_key_exists('allow_cid',$arr)) + $args['allow_cid'] = $arr['allow_cid']; + if(array_key_exists('allow_gid',$arr)) + $args['allow_gid'] = $arr['allow_gid']; + if(array_key_exists('deny_cid',$arr)) + $args['deny_cid'] = $arr['deny_cid']; + if(array_key_exists('deny_gid',$arr)) + $args['deny_gid'] = $arr['deny_gid']; + + $args['created'] = $created; + $args['edited'] = $edited; + + $p = photo_upload($channel,$observer,$args); if($p['success']) { $ret['body'] = $p['body']; } diff --git a/include/photos.php b/include/photos.php index cb7fabc98..dc7df2d0d 100644 --- a/include/photos.php +++ b/include/photos.php @@ -52,12 +52,21 @@ function photo_upload($channel, $observer, $args) { // Set to default channel permissions. If the parent directory (album) has permissions set, // use those instead. If we have specific permissions supplied, they take precedence over - // all other settings. - - $str_group_allow = $channel['channel_allow_gid']; - $str_contact_allow = $channel['channel_allow_cid']; - $str_group_deny = $channel['channel_deny_gid']; - $str_contact_deny = $channel['channel_deny_cid']; + // all other settings. 'allow_cid' being passed from an external source takes priority over channel settings. + // ...messy... needs re-factoring once the photos/files integration stabilises + + if(array_key_exists('allow_cid',$args)) { + $str_group_allow = $args['allow_gid']; + $str_contact_allow = $args['allow_cid']; + $str_group_deny = $args['deny_gid']; + $str_contact_deny = $args['deny_cid']; + } + else { + $str_group_allow = $channel['channel_allow_gid']; + $str_contact_allow = $channel['channel_allow_cid']; + $str_group_deny = $channel['channel_deny_gid']; + $str_contact_deny = $channel['channel_deny_cid']; + } if($args['directory']) { $str_group_allow = $args['directory']['allow_gid']; -- cgit v1.2.3 From 8fb1356623f9a2b6089e97103b593158e67c8676 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 17:49:57 -0700 Subject: required for future work --- include/conversation.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 76a2f47d1..8bbb87e2c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -404,7 +404,9 @@ function count_descendants($item) { * @brief Check if the activity of the item is visible. * * likes (etc.) can apply to other things besides posts. Check if they are post - * children, in which case we handle them specially. + * children, in which case we handle them specially. Activities which are unrecognised + * as having special meaning and hidden will be treated as posts or comments and visible + * in the stream. * * @param array $item * @return boolean @@ -412,12 +414,21 @@ function count_descendants($item) { function visible_activity($item) { $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $post_types = array(ACTIVITY_OBJ_NOTE,ACTIVITY_OBJ_COMMENT,basename(ACTIVITY_OBJ_NOTE),basename(ACTIVITY_OBJ_COMMENT)); + foreach ($hidden_activities as $act) { if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { return false; } } + // In order to share edits with networks which have no concept of editing, we'll create + // separate activities to indicate the edit. Our network will not require them, since our + // edits are automatically applied and the activity indicated. + + if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) + return false; + return true; } -- cgit v1.2.3 From d1c23477dfb0ee48cf652d6e63969ed5a3809b18 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 20:20:41 -0700 Subject: support likes on comments with diaspora owner by sending as activity --- include/diaspora.php | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 74a56dd79..61556fd9d 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2742,21 +2742,26 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { // versions of Diaspora (i.e. Diaspora-pistos) support // likes on comments + + // That version is now dead so detect a "sublike" and + // just send it as an activity. + + $sublike = false; + + if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) { - $p = q("select * from item where mid = '%s' limit 1", - dbesc($item['thr_parent']) - ); - } - else { - // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always - // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. - // The only item with `parent` and `id` as the parent id is the parent item. - $p = q("select * from item where parent = %d and id = %d limit 1", - intval($item['parent']), - intval($item['parent']) - ); + $sublike = true; } + + // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always + // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. + // The only item with `parent` and `id` as the parent id is the parent item. + $p = q("select * from item where parent = %d and id = %d limit 1", + intval($item['parent']), + intval($item['parent']) + ); + if($p) $parent = $p[0]; else { @@ -2771,12 +2776,12 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { if( $item['item_restrict'] & ITEM_DELETED) { $relay_retract = true; - $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); + $target_type = ( ($item['verb'] === ACTIVITY_LIKE && (! $sublike)) ? 'Like' : 'Comment'); $sql_sign_id = 'retract_iid'; $tpl = get_markup_template('diaspora_relayable_retraction.tpl'); } - elseif($item['verb'] === ACTIVITY_LIKE) { + elseif(($item['verb'] === ACTIVITY_LIKE) && (! $sublike)) { $like = true; $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); -- cgit v1.2.3 From 0d2c90cc2e4df2b5a7dc83c735ea60bd77c6946e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 22:11:50 -0700 Subject: add item info to photo detail in api --- include/api.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 2c25b8700..5e6cba38d 100644 --- a/include/api.php +++ b/include/api.php @@ -645,7 +645,27 @@ require_once('include/items.php'); if(array_key_exists('os_storage',$r[0]) && intval($r[0]['os_storage'])) $data = file_get_contents($data); $r[0]['data'] = base64_encode($data); - json_return_and_die($r[0]); + $ret = array('photo' => $r[0]); + $i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1", + intval(local_channel()), + dbesc($_REQUEST['photo_id']) + ); + if($i) { + $ii = q("select * from item where parent = %d order by id", + intval($i[0]['id']) + ); + if($ii) { + xchan_query($ii,true,0); + $ii = fetch_post_tags($ii,true); + if($ii) { + $ret['item'] = array(); + foreach($ii as $iii) + $ret['item'][] = encode_item($iii); + } + } + } + + json_return_and_die($ret); } killme(); } -- cgit v1.2.3 From 9cebd249871389bb756cb4d73e6719200120e413 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 22:13:20 -0700 Subject: change attach_store to allow a predefined item to accompany a photo --- include/attach.php | 2 + include/photos.php | 124 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 82 insertions(+), 44 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index a23f0f81a..620c7620c 100644 --- a/include/attach.php +++ b/include/attach.php @@ -758,6 +758,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $args['created'] = $created; $args['edited'] = $edited; + if($arr['item']) + $args['item'] = $arr['item']; $p = photo_upload($channel,$observer,$args); if($p['success']) { diff --git a/include/photos.php b/include/photos.php index dc7df2d0d..4f5e1d077 100644 --- a/include/photos.php +++ b/include/photos.php @@ -270,62 +270,98 @@ function photo_upload($channel, $observer, $args) { } } - $title = ''; - $mid = item_message_id(); + if($args['item']) { + foreach($args['item'] as $i) { - $arr = array(); + $item = get_item_elements($i); + $force = false; - if($lat && $lon) - $arr['coord'] = $lat . ' ' . $lon; - - $arr['aid'] = $account_id; - $arr['uid'] = $channel_id; - $arr['mid'] = $mid; - $arr['parent_mid'] = $mid; - $arr['item_hidden'] = $item_hidden; - $arr['resource_type'] = 'photo'; - $arr['resource_id'] = $photo_hash; - $arr['owner_xchan'] = $channel['channel_hash']; - $arr['author_xchan'] = $observer['xchan_hash']; - $arr['title'] = $title; - $arr['allow_cid'] = $str_contact_allow; - $arr['allow_gid'] = $str_group_allow; - $arr['deny_cid'] = $str_contact_deny; - $arr['deny_gid'] = $str_group_deny; - $arr['verb'] = ACTIVITY_POST; - $arr['item_wall'] = 1; - $arr['item_origin'] = 1; - $arr['item_thread_top'] = 1; + if($item['mid'] === $item['parent_mid']) { - $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; + $item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' + . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' + . '[/zrl]'; + $item['sig'] = ''; + $force = true; - // We should also put a width_x_height on large photos. Left as an exercise for - // devs looking fo simple stuff to fix. - - $larger = feature_enabled($channel['channel_id'], 'large_photos'); - if($larger) { - $tag = '[zmg]'; - if($r2) - $smallest = 1; - else - $smallest = 0; + } + $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", + dbesc($item['mid']), + intval($channel['channel_id']) + ); + if($r) { + if(($item['edited'] > $r[0]['edited']) || $force) { + $item['id'] = $r[0]['id']; + $item['uid'] = $channel['channel_id']; + item_store_update($item); + continue; + } + } + else { + $item['aid'] = $channel['channel_account_id']; + $item['uid'] = $channel['channel_id']; + $item_result = item_store($item); + } + } } else { - if ($width_x_height) - $tag = '[zmg=' . $width_x_height. ']'; - else + $title = ''; + $mid = item_message_id(); + + $arr = array(); + + if($lat && $lon) + $arr['coord'] = $lat . ' ' . $lon; + + $arr['aid'] = $account_id; + $arr['uid'] = $channel_id; + $arr['mid'] = $mid; + $arr['parent_mid'] = $mid; + $arr['item_hidden'] = $item_hidden; + $arr['resource_type'] = 'photo'; + $arr['resource_id'] = $photo_hash; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $observer['xchan_hash']; + $arr['title'] = $title; + $arr['allow_cid'] = $str_contact_allow; + $arr['allow_gid'] = $str_group_allow; + $arr['deny_cid'] = $str_contact_deny; + $arr['deny_gid'] = $str_group_deny; + $arr['verb'] = ACTIVITY_POST; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; + + $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; + + // We should also put a width_x_height on large photos. Left as an exercise for + // devs looking for simple stuff to fix. + + $larger = feature_enabled($channel['channel_id'], 'large_photos'); + if($larger) { $tag = '[zmg]'; - } + if($r2) + $smallest = 1; + else + $smallest = 0; + } + else { + if ($width_x_height) + $tag = '[zmg=' . $width_x_height. ']'; + else + $tag = '[zmg]'; + } - $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' + $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' . '[/zrl]'; - $result = item_store($arr); - $item_id = $result['item_id']; + $result = item_store($arr); + $item_id = $result['item_id']; - if($visible) - proc_run('php', "include/notifier.php", 'wall-new', $item_id); + if($visible) + proc_run('php', "include/notifier.php", 'wall-new', $item_id); + } $ret['success'] = true; $ret['item'] = $arr; -- cgit v1.2.3 From 0b5bad4aa7968d22e1e9cf92a42d86579bd811ec Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 22:58:53 -0700 Subject: use extended export format for items in api photo_detail --- include/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index 5e6cba38d..027779558 100644 --- a/include/api.php +++ b/include/api.php @@ -660,7 +660,7 @@ require_once('include/items.php'); if($ii) { $ret['item'] = array(); foreach($ii as $iii) - $ret['item'][] = encode_item($iii); + $ret['item'][] = encode_item($iii,true); } } } -- cgit v1.2.3 From 58ffa31e911ad985078107638aabe7c0a864f5ce Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 23:00:33 -0700 Subject: redphotos updates --- include/photos.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/photos.php b/include/photos.php index 4f5e1d077..04018ac0d 100644 --- a/include/photos.php +++ b/include/photos.php @@ -281,7 +281,14 @@ function photo_upload($channel, $observer, $args) { $item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' . '[/zrl]'; - $item['sig'] = ''; + + if($item['author_xchan'] === $channel['channel_hash']) { + $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey'])); + $item['item_verified'] = 1; + } + else { + $item['sig'] = ''; + } $force = true; } -- cgit v1.2.3