From: Michael Date: Thu, 21 Jul 2022 05:42:53 +0000 (+0000) Subject: database.sql updated, standards fixed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d4a536137d368fd039e8cdeb44761e074234d8af;p=friendica.git database.sql updated, standards fixed --- diff --git a/database.sql b/database.sql index 01bd84b00b..d8b26cebeb 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2022.09-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1473 +-- DB_UPDATE_VERSION 1474 -- ------------------------------------------ @@ -724,6 +724,39 @@ CREATE TABLE IF NOT EXISTS `hook` ( UNIQUE INDEX `hook_file_function` (`hook`,`file`,`function`) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='addon hook registry'; +-- +-- TABLE inbox-entry +-- +CREATE TABLE IF NOT EXISTS `inbox-entry` ( + `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', + `activity-id` varbinary(255) COMMENT 'id of the incoming activity', + `object-id` varbinary(255) COMMENT '', + `in-reply-to-id` varbinary(255) COMMENT '', + `type` varchar(64) COMMENT 'Type of the activity', + `object-type` varchar(64) COMMENT 'Type of the object activity', + `object-object-type` varchar(64) COMMENT 'Type of the object\'s object activity', + `received` datetime COMMENT 'Receiving date', + `activity` mediumtext COMMENT 'The JSON activity', + `signer` varchar(255) COMMENT '', + `push` boolean NOT NULL DEFAULT '0' COMMENT '', + PRIMARY KEY(`id`), + UNIQUE INDEX `activity-id` (`activity-id`), + INDEX `object-id` (`object-id`), + INDEX `received` (`received`) +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Incoming activity'; + +-- +-- TABLE inbox-entry-receiver +-- +CREATE TABLE IF NOT EXISTS `inbox-entry-receiver` ( + `queue-id` int unsigned NOT NULL COMMENT '', + `uid` mediumint unsigned NOT NULL COMMENT 'User id', + PRIMARY KEY(`queue-id`,`uid`), + INDEX `uid` (`uid`), + FOREIGN KEY (`queue-id`) REFERENCES `inbox-entry` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Receiver for the incoming activity'; + -- -- TABLE inbox-status -- diff --git a/doc/database.md b/doc/database.md index fcff590e13..0effb1754a 100644 --- a/doc/database.md +++ b/doc/database.md @@ -31,6 +31,8 @@ Database Tables | [gserver](help/database/db_gserver) | Global servers | | [gserver-tag](help/database/db_gserver-tag) | Tags that the server has subscribed | | [hook](help/database/db_hook) | addon hook registry | +| [inbox-entry](help/database/db_inbox-entry) | Incoming activity | +| [inbox-entry-receiver](help/database/db_inbox-entry-receiver) | Receiver for the incoming activity | | [inbox-status](help/database/db_inbox-status) | Status of ActivityPub inboxes | | [intro](help/database/db_intro) | | | [item-uri](help/database/db_item-uri) | URI and GUID for items | diff --git a/doc/database/db_inbox-entry-receiver.md b/doc/database/db_inbox-entry-receiver.md new file mode 100644 index 0000000000..f905289d27 --- /dev/null +++ b/doc/database/db_inbox-entry-receiver.md @@ -0,0 +1,30 @@ +Table inbox-entry-receiver +=========== + +Receiver for the incoming activity + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| -------- | ----------- | ------------------ | ---- | --- | ------- | ----- | +| queue-id | | int unsigned | NO | PRI | NULL | | +| uid | User id | mediumint unsigned | NO | PRI | NULL | | + +Indexes +------------ + +| Name | Fields | +| ------- | ------------- | +| PRIMARY | queue-id, uid | +| uid | uid | + +Foreign Keys +------------ + +| Field | Target Table | Target Field | +|-------|--------------|--------------| +| queue-id | [inbox-entry](help/database/db_inbox-entry) | id | +| uid | [user](help/database/db_user) | uid | + +Return to [database documentation](help/database) diff --git a/doc/database/db_inbox-entry.md b/doc/database/db_inbox-entry.md new file mode 100644 index 0000000000..56dee2c620 --- /dev/null +++ b/doc/database/db_inbox-entry.md @@ -0,0 +1,34 @@ +Table inbox-entry +=========== + +Incoming activity + +Fields +------ + +| Field | Description | Type | Null | Key | Default | Extra | +| ------------------ | ------------------------------------ | -------------- | ---- | --- | ------- | -------------- | +| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | +| activity-id | id of the incoming activity | varbinary(255) | YES | | NULL | | +| object-id | | varbinary(255) | YES | | NULL | | +| in-reply-to-id | | varbinary(255) | YES | | NULL | | +| type | Type of the activity | varchar(64) | YES | | NULL | | +| object-type | Type of the object activity | varchar(64) | YES | | NULL | | +| object-object-type | Type of the object's object activity | varchar(64) | YES | | NULL | | +| received | Receiving date | datetime | YES | | NULL | | +| activity | The JSON activity | mediumtext | YES | | NULL | | +| signer | | varchar(255) | YES | | NULL | | +| push | | boolean | NO | | 0 | | + +Indexes +------------ + +| Name | Fields | +| ----------- | ------------------- | +| PRIMARY | id | +| activity-id | UNIQUE, activity-id | +| object-id | object-id | +| received | received | + + +Return to [database documentation](help/database) diff --git a/src/Protocol/ActivityPub/Queue.php b/src/Protocol/ActivityPub/Queue.php index 12bf7e268d..c3605ebb64 100644 --- a/src/Protocol/ActivityPub/Queue.php +++ b/src/Protocol/ActivityPub/Queue.php @@ -44,7 +44,7 @@ class Queue public static function add(array $activity, string $type, int $uid, string $http_signer, bool $push): array { $fields = [ - 'activity-id' => $activity['id'], + 'activity-id' => $activity['id'], 'object-id' => $activity['object_id'], 'type' => $type, 'object-type' => $activity['object_type'], @@ -104,9 +104,9 @@ class Queue Logger::debug('Processing queue entry', ['id' => $entry['id'], 'type' => $entry['type'], 'object-type' => $entry['object-type'], 'uri' => $entry['object-id'], 'in-reply-to' => $entry['in-reply-to-id']]); - $activity = json_decode($entry['activity'], true); - $type = $entry['type']; - $push = $entry['push']; + $activity = json_decode($entry['activity'], true); + $type = $entry['type']; + $push = $entry['push']; $activity['entry-id'] = $entry['id'];