Store conversation data for self created posts as well
This commit is contained in:
parent
c0b5339691
commit
edbbdf9761
2 changed files with 21 additions and 0 deletions
|
@ -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.
|
||||
|
|
14
mod/item.php
14
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']),
|
||||
|
|
Loading…
Reference in a new issue