diff options
author | zotlabs <mike@macgirvin.com> | 2018-11-12 18:25:55 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-11-12 18:25:55 -0800 |
commit | 1a2df9c51c4692fce433f483aba1b91738609df7 (patch) | |
tree | 2d62c4369e621b24b0f6047c62aca1599042f6a9 | |
parent | 770fdb2b7d095d763d43ffe8d2f6b5b2182673cb (diff) | |
download | volse-hubzilla-1a2df9c51c4692fce433f483aba1b91738609df7.tar.gz volse-hubzilla-1a2df9c51c4692fce433f483aba1b91738609df7.tar.bz2 volse-hubzilla-1a2df9c51c4692fce433f483aba1b91738609df7.zip |
item uuid changes
-rw-r--r-- | Zotlabs/Module/Item.php | 4 | ||||
-rwxr-xr-x | include/items.php | 10 | ||||
-rw-r--r-- | include/text.php | 21 |
3 files changed, 14 insertions, 21 deletions
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 1e1df9d56..464daa516 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -732,7 +732,8 @@ class Item extends \Zotlabs\Web\Controller { $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); if(! $mid) { - $mid = (($message_id) ? $message_id : item_message_id()); + $uuid = (($message_id) ? $message_id : item_message_id()); + $mid = z_root() . '/item/' . $uuid; } @@ -787,6 +788,7 @@ class Item extends \Zotlabs\Web\Controller { $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; + $datarray['uuid'] = $uuid; $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; diff --git a/include/items.php b/include/items.php index 24f1be84f..3d707a492 100755 --- a/include/items.php +++ b/include/items.php @@ -393,7 +393,11 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) { if(! array_key_exists('mimetype',$arr)) $arr['mimetype'] = 'text/bbcode'; - $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id()); + + if(! $arr['mid']) { + $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id()); + } + $arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? $arr['parent_mid'] : $arr['mid']); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? $arr['thr_parent'] : $arr['mid']); @@ -635,6 +639,7 @@ function get_item_elements($x,$allow_code = false) { if(mb_strlen($arr['title']) > 255) $arr['title'] = mb_substr($arr['title'],0,255); + $arr['uuid'] = (($x['uuid']) ? htmlspecialchars($x['uuid'], ENT_COMPAT,'UTF-8',false) : ''); $arr['app'] = (($x['app']) ? htmlspecialchars($x['app'], ENT_COMPAT,'UTF-8',false) : ''); $arr['route'] = (($x['route']) ? htmlspecialchars($x['route'], ENT_COMPAT,'UTF-8',false) : ''); $arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); @@ -1070,6 +1075,7 @@ function encode_item($item,$mirror = false) { $x['item_blocked'] = $item['item_blocked']; } + $x['uuid'] = $item['uuid']; $x['message_id'] = $item['mid']; $x['message_top'] = $item['parent_mid']; $x['message_parent'] = $item['thr_parent']; @@ -1648,6 +1654,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : ''); $arr['route'] = ((x($arr,'route')) ? trim($arr['route']) : ''); + $arr['uuid'] = ((x($arr,'uuid')) ? trim($arr['uuid']) : ''); $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 ); $arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 ); $arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 ); @@ -2183,6 +2190,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) { $arr['route'] = ((array_key_exists('route',$arr)) ? trim($arr['route']) : $orig[0]['route']); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']); + $arr['uuid'] = ((x($arr,'uuid')) ? notags(trim($arr['uuid'])) : $orig[0]['uuid']); $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']); diff --git a/include/text.php b/include/text.php index 3d351f7dc..d3130023c 100644 --- a/include/text.php +++ b/include/text.php @@ -574,18 +574,9 @@ function alt_pager($i, $more = '', $less = '') { * @return string a unique id */ function item_message_id() { - do { - $dups = false; - $hash = random_string(); - $mid = $hash . '@' . App::get_hostname(); - $r = q("SELECT id FROM item WHERE mid = '%s' LIMIT 1", - dbesc($mid)); - if($r) - $dups = true; - } while($dups == true); + return new_uuid(); - return $mid; } /** @@ -596,17 +587,9 @@ function item_message_id() { * @return string a uniqe hash */ function photo_new_resource() { - do { - $found = false; - $resource = hash('md5', uniqid(mt_rand(), true)); - $r = q("SELECT id FROM photo WHERE resource_id = '%s' LIMIT 1", - dbesc($resource)); - if($r) - $found = true; - } while($found === true); + return new_uuid(); - return $resource; } /** |