Skip to content

Commit

Permalink
Add conversation storage for Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypolite Petovan committed Aug 5, 2018
1 parent 6678208 commit c4e69b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Model/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* @file src/Model/Conversation
*/

namespace Friendica\Model;

use Friendica\Database\DBA;
Expand Down Expand Up @@ -29,8 +30,10 @@ 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', NETWORK_PHANTOM),
[NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_TWITTER]) && !empty($arr['uri'])) {
$conversation = ['item-uri' => $arr['uri'], 'received' => DateTimeFormat::utcNow()];

if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
Expand Down Expand Up @@ -70,11 +73,13 @@ public static function insert($arr) {
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);
}
}
}
Expand Down

0 comments on commit c4e69b7

Please sign in to comment.