From dd204ec34f473d7e0b133d35b08f3c4dc8d3ffef Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 1 Feb 2024 11:42:55 +0000 Subject: start using uuid for internal reference instead of base64 encoded mid --- include/conversation.php | 18 +++++++++--------- include/event.php | 2 +- include/items.php | 15 ++++++++++----- 3 files changed, 20 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c7057b09d..9683e02f0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -789,16 +789,14 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0) $is_new = true; - $conv_link_mid = (($mode == 'moderate') ? gen_link_id($item['parent_mid']) : gen_link_id($item['mid'])); - - $conv_link = z_root() . '/display/' . $conv_link_mid; + $conv_link = z_root() . '/display/' . $item['uuid']; if(local_channel()) { - $conv_link = z_root() . '/hq/' . $conv_link_mid; + $conv_link = z_root() . '/hq/' . $item['uuid']; } if ($mode === 'pubstream-new') { - $conv_link = z_root() . '/pubstream?mid=' . $conv_link_mid; + $conv_link = z_root() . '/pubstream?mid=' . $item['uuid']; } $contact = []; @@ -816,8 +814,8 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa 'delete' => t('Delete'), 'preview_lbl' => $preview_lbl, 'id' => (($preview) ? 'P0' : $item['item_id']), - 'mid' => gen_link_id($item['mid']), - 'mids' => json_encode([gen_link_id($item['mid'])]), + 'mid' => $item['uuid'], + 'mids' => json_encode([$item['uuid']]), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_link), 'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), 'profile_url' => $profile_link, @@ -918,6 +916,8 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa continue; } + $mid_uuid_map[$item['mid']] = $item['uuid']; + $item['pagedrop'] = $page_dropping; if($item['id'] == $item['parent'] || $r_preview) { @@ -936,7 +936,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa } } - $threads = $conv->get_template_data($conv_responses); + $threads = $conv->get_template_data($conv_responses, $mid_uuid_map); if(!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = array(); @@ -1246,7 +1246,7 @@ function builtin_activity_puller($item, &$conv_responses) { if(! $item['thr_parent']) $item['thr_parent'] = $item['parent_mid']; - $conv_responses[$mode]['mids'][$item['thr_parent']][] = gen_link_id($item['mid']); + $conv_responses[$mode]['mids'][$item['thr_parent']][] = $item['uuid']; if($item['obj_type'] === 'Answer') continue; diff --git a/include/event.php b/include/event.php index da504c2d7..bb24030cf 100644 --- a/include/event.php +++ b/include/event.php @@ -1417,7 +1417,7 @@ function event_store_item($arr, $event) { if($wall) $item_arr['plink'] = $item_arr['mid']; else - $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); + $item_arr['plink'] = z_root() . '/display/' . $item_arr['uuid']; set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); diff --git a/include/items.php b/include/items.php index 56534c4e4..f30a986bb 100644 --- a/include/items.php +++ b/include/items.php @@ -1775,13 +1775,18 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $d1 = new DateTime('now +10 minutes', new DateTimeZone('UTC')); $d2 = new DateTime($arr['created'] . '+00:00'); - if($d2 > $d1) + + if($d2 > $d1) { $arr['item_delayed'] = 1; + } - $arr['llink'] = z_root() . '/display/' . gen_link_id($arr['mid']); + if(empty($arr['llink'])) { + $arr['llink'] = z_root() . '/display/' . $arr['uuid']; + } - if(! $arr['plink']) + if(empty($arr['plink'])) { $arr['plink'] = $arr['llink']; + } if($arr['parent_mid'] === $arr['mid']) { $parent_id = 0; @@ -2501,7 +2506,7 @@ function send_status_notifications($post_id,$item) { if($unfollowed) return; - $link = z_root() . '/display/' . gen_link_id($item['mid']); + $link = z_root() . '/display/' . $item['uuid']; $y = q("select id from notify where link = '%s' and uid = %d limit 1", dbesc($link), @@ -3174,7 +3179,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false $item['mid'] = z_root() . '/item/' . $item['uuid']; $item['parent_mid'] = $item['mid']; $item['thr_parent'] = $item['mid']; - $item['llink'] = z_root() . '/display/' . gen_link_id($item['mid']); + $item['llink'] = z_root() . '/display/' . $item['uuid']; } $r = q("UPDATE item SET author_xchan = '%s', mid = '%s', parent_mid = '%s', thr_parent = '%s', llink = '%s' WHERE id = %d", -- cgit v1.2.3