X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FConversation.php;h=0692a7341234f66f81530474270af6e4a64f85e8;hb=8dc5b04be7cd9cb2eb77ed9824815efe27369bee;hp=98db86188f89c5872b578324f5d3d351a5d2108f;hpb=cfa68c52b9117616fa95a4639ad74e7d220d193d;p=friendica.git diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 98db86188f..0692a73412 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -2,8 +2,10 @@ /** * @file src/Model/Conversation */ + namespace Friendica\Model; +use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; @@ -11,13 +13,17 @@ require_once "include/dba.php"; class Conversation { - const PROTOCOL_UNKNOWN = 0; - const PROTOCOL_DFRN = 1; - const PROTOCOL_DIASPORA = 2; - const PROTOCOL_OSTATUS_SALMON = 3; - const PROTOCOL_OSTATUS_FEED = 4; // Deprecated - const PROTOCOL_GS_CONVERSATION = 5; // Deprecated - const PROTOCOL_SPLITTED_CONV = 6; + /* + * These constants represent the parcel format used to transport a conversation independently of the message protocol. + * It currently is stored in the "protocol" field for legacy reasons. + */ + const PARCEL_UNKNOWN = 0; + const PARCEL_DFRN = 1; + const PARCEL_DIASPORA = 2; + const PARCEL_SALMON = 3; + const PARCEL_FEED = 4; // Deprecated + const PARCEL_SPLIT_CONVERSATION = 6; + const PARCEL_TWITTER = 67; /** * @brief Store the conversation data @@ -25,13 +31,16 @@ class Conversation * @param array $arr Item array with conversation data * @return array Item array with removed conversation data */ - public static function insert($arr) { - if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) { + public static function insert(array $arr) + { + if (in_array(defaults($arr, 'network', Protocol::PHANTOM), + [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) { $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()]; if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) { $conversation['reply-to-uri'] = $arr['parent-uri']; } + if (isset($arr['thr-parent']) && ($arr['thr-parent'] != $arr['uri'])) { $conversation['reply-to-uri'] = $arr['thr-parent']; } @@ -66,11 +75,13 @@ class Conversation unset($conversation['source']); } if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) { - logger('Conversation: update for '.$conversation['item-uri'].' from '.$old_conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG); + logger('Conversation: update for ' . $conversation['item-uri'] . ' from ' . $old_conv['protocol'] . ' to ' . $conversation['protocol'] . ' failed', + LOGGER_DEBUG); } } else { if (!DBA::insert('conversation', $conversation, true)) { - logger('Conversation: insert for '.$conversation['item-uri'].' (protocol '.$conversation['protocol'].') failed', LOGGER_DEBUG); + logger('Conversation: insert for ' . $conversation['item-uri'] . ' (protocol ' . $conversation['protocol'] . ') failed', + LOGGER_DEBUG); } } }