diff --git a/database.sql b/database.sql index 04a35634e0..3cb87fc90a 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2020.03-dev (Dalmatian Bellflower) --- DB_UPDATE_VERSION 1334 +-- DB_UPDATE_VERSION 1335 -- ------------------------------------------ @@ -279,6 +279,7 @@ CREATE TABLE IF NOT EXISTS `conversation` ( `conversation-uri` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation URI', `conversation-href` varbinary(255) NOT NULL DEFAULT '' COMMENT 'GNU Social conversation link', `protocol` tinyint unsigned NOT NULL DEFAULT 255 COMMENT 'The protocol of the item', + `direction` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'How the message arrived here: 1=push, 2=pull', `source` mediumtext COMMENT 'Original source', `received` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Receiving date', PRIMARY KEY(`item-uri`), diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 661cfcd6af..80103b2dcc 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -41,6 +41,19 @@ class Conversation const PARCEL_TWITTER = 67; const PARCEL_UNKNOWN = 255; + /** + * Unknown message direction + */ + const UNKNOWN = 0; + /** + * The message had been pushed to this sytem + */ + const PUSH = 1; + /** + * The message had been fetched by our system + */ + const PULL = 2; + public static function getByItemUri($item_uri) { return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]); @@ -79,6 +92,10 @@ class Conversation $conversation['protocol'] = $arr['protocol']; } + if (isset($arr['direction'])) { + $conversation['direction'] = $arr['direction']; + } + if (isset($arr['source'])) { $conversation['source'] = $arr['source']; } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 6d6c652fde..e79fcaff68 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -490,12 +490,7 @@ class Processor } if (isset($activity['push'])) { - $push_app = $activity['push'] ? '📨' : '🚜'; - if (!empty($item['app'])) { - $item['app'] .= ' (' . $push_app . ')'; - } else { - $item['app'] .= $push_app; - } + $item['direction'] = $activity['push'] ? Conversation::PUSH : Conversation::PULL; } $item['plink'] = $activity['alternate-url'] ?? $item['uri']; diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 39655f45d7..97eb3b62c6 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -174,9 +174,10 @@ class Receiver /** * Prepare the object array * - * @param array $activity - * @param integer $uid User ID - * @param $trust_source + * @param array $activity Array with activity data + * @param integer $uid User ID + * @param boolean $push Message had been pushed to our system + * @param boolean $trust_source Do we trust the source? * * @return array with object data * @throws \Friendica\Network\HTTPException\InternalServerErrorException @@ -312,6 +313,7 @@ class Receiver * @param string $body * @param integer $uid User ID * @param boolean $trust_source Do we trust the source? + * @param boolean $push Message had been pushed to our system * @throws \Exception */ public static function processActivity($activity, $body = '', $uid = null, $trust_source = false, $push = false) diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 5b2e3bc091..0c0b289414 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -51,7 +51,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1334); + define('DB_UPDATE_VERSION', 1335); } return [ @@ -342,6 +342,7 @@ return [ "conversation-uri" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation URI"], "conversation-href" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => "GNU Social conversation link"], "protocol" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "255", "comment" => "The protocol of the item"], + "direction" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "How the message arrived here: 1=push, 2=pull"], "source" => ["type" => "mediumtext", "comment" => "Original source"], "received" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Receiving date"], ],