-- ------------------------------------------
-- Friendica 2022.09-dev (Giant Rhubarb)
--- DB_UPDATE_VERSION 1473
+-- DB_UPDATE_VERSION 1474
-- ------------------------------------------
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
--
| [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 |
--- /dev/null
+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)
--- /dev/null
+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)
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'],
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'];