From edbbdf97618a2588479dca642c03bf927e947abc Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 29 Apr 2017 05:44:13 +0000 Subject: [PATCH] Store conversation data for self created posts as well --- include/items.php | 7 +++++++ mod/item.php | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/items.php b/include/items.php index 6456fa2cba..9f948485a2 100644 --- a/include/items.php +++ b/include/items.php @@ -410,6 +410,12 @@ function uri_to_guid($uri, $host = "") { return $guid_prefix.$host_hash; } +/** + * @brief Store the conversation data + * + * @param array $arr Item array with conversation data + * @return array Item array with removed conversation data + */ function store_conversation($arr) { if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { $conversation = array('item-uri' => $arr['uri'], 'received' => dbm::date()); @@ -476,6 +482,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $arr['origin'] = 1; $arr['last-child'] = 1; $arr['network'] = NETWORK_DFRN; + $arr['protocol'] = PROTOCOL_DFRN; // We have to avoid duplicates. So we create the GUID in form of a hash of the plink or uri. // In difference to the call to "uri_to_guid" several lines below we add the hash of our own host. diff --git a/mod/item.php b/mod/item.php index 8bf922d97c..d8be579ff9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -723,6 +723,18 @@ function item_post(App $a) { $datarray['last-child'] = 1; $datarray['visible'] = 1; + $datarray['protocol'] = PROTOCOL_DFRN; + + $r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $datarray['parent-uri']); + if (dbm::is_result($r)) { + if ($r['conversation-uri'] != '') { + $datarray['conversation-uri'] = $r['conversation-uri']; + } + if ($r['conversation-href'] != '') { + $datarray['conversation-href'] = $r['conversation-href']; + } + } + if ($orig_post) { $datarray['edit'] = true; } @@ -762,6 +774,8 @@ function item_post(App $a) { // Fill the cache field put_item_in_cache($datarray); + $datarray = store_conversation($datarray); + if ($orig_post) { $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($datarray['title']),