1
1
Fork 0

Add conversation storage for Twitter

This commit is contained in:
Hypolite Petovan 2018-08-05 12:34:33 +02:00
parent 6678208915
commit c4e69b7766

View file

@ -2,6 +2,7 @@
/** /**
* @file src/Model/Conversation * @file src/Model/Conversation
*/ */
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -29,8 +30,10 @@ class Conversation
* @param array $arr Item array with conversation data * @param array $arr Item array with conversation data
* @return array Item array with removed conversation data * @return array Item array with removed conversation data
*/ */
public static function insert($arr) { public static function insert(array $arr)
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) { {
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM),
[NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_TWITTER]) && !empty($arr['uri'])) {
$conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()]; $conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) { if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
@ -70,11 +73,13 @@ class Conversation
unset($conversation['source']); unset($conversation['source']);
} }
if (!DBA::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) { 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 { } else {
if (!DBA::insert('conversation', $conversation, true)) { 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);
} }
} }
} }