`received` datetime COMMENT 'Receiving date',
`activity` mediumtext COMMENT 'The JSON activity',
`signer` varchar(255) COMMENT '',
- `push` boolean NOT NULL DEFAULT '0' COMMENT '',
+ `push` boolean COMMENT 'Is the entry pushed or have pulled it?',
+ `trust` boolean COMMENT 'Do we trust this entry?',
`wid` int unsigned COMMENT 'Workerqueue id',
PRIMARY KEY(`id`),
UNIQUE INDEX `activity-id` (`activity-id`),
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 | |
-| conversation | | 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 | |
-| wid | Workerqueue id | int unsigned | YES | | NULL | |
+| 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 | |
+| conversation | | 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 | Is the entry pushed or have pulled it? | boolean | YES | | NULL | |
+| trust | Do we trust this entry? | boolean | YES | | NULL | |
+| wid | Workerqueue id | int unsigned | YES | | NULL | |
Indexes
------------
Logger::notice('Parent not found. Try to refetch it.', ['parent' => $activity['reply-to-id'], 'recursion-depth' => $recursion_depth]);
if ($recursion_depth < 10) {
$result = self::fetchMissingActivity($activity['reply-to-id'], $activity, '', Receiver::COMPLETION_AUTO);
- if (empty($result) && self::ActivityIsGone($activity['reply-to-id'])) {
+ if (empty($result) && self::isActivityGone($activity['reply-to-id'])) {
// Recursively delete this and all depending entries
Queue::deleteById($activity['entry-id']);
return [];
*
* @return boolean
*/
- private static function ActivityIsGone(string $url): bool
+ private static function isActivityGone(string $url): bool
{
$curlResult = HTTPSignature::fetchRaw($url, 0);
* @param boolean $push
* @return array
*/
- public static function add(array $activity, string $type, int $uid, string $http_signer, bool $push): array
+ public static function add(array $activity, string $type, int $uid, string $http_signer, bool $push, bool $trust_source): array
{
$fields = [
'activity-id' => $activity['id'],
'activity' => json_encode($activity, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
'received' => DateTimeFormat::utcNow(),
'push' => $push,
+ 'trust' => $trust_source,
];
if (!empty($activity['reply-to-id'])) {
*/
public static function processAll()
{
- $entries = DBA::select('inbox-entry', ['id', 'type', 'object-type', 'object-id', 'in-reply-to-id'], ["`wid` IS NULL"], ['order' => ['id' => true]]);
+ $entries = DBA::select('inbox-entry', ['id', 'type', 'object-type', 'object-id', 'in-reply-to-id'], ["`trust` AND `wid` IS NULL"], ['order' => ['id' => true]]);
while ($entry = DBA::fetch($entries)) {
// We don't need to process entries that depend on already existing entries.
if (!empty($entry['in-reply-to-id']) && DBA::exists('inbox-entry', ["`id` != ? AND `object-id` = ?", $entry['id'], $entry['in-reply-to-id']])) {
$type = $object_data['type'];
}
- if (!$trust_source) {
- Logger::info('Activity trust could not be achieved.', ['id' => $object_data['object_id'], 'type' => $type, 'signer' => $signer, 'actor' => $actor, 'attributedTo' => $attributed_to]);
- return;
- }
-
if (!empty($body) && empty($object_data['raw'])) {
$object_data['raw'] = $body;
}
$object_data['object_activity'] = $activity;
}
- $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push);
+ $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source);
+
+ if (!$trust_source) {
+ Logger::info('Activity trust could not be achieved.', ['id' => $object_data['object_id'], 'type' => $type, 'signer' => $signer, 'actor' => $actor, 'attributedTo' => $attributed_to]);
+ return;
+ }
if (!empty($activity['recursion-depth'])) {
$object_data['recursion-depth'] = $activity['recursion-depth'];
"received" => ["type" => "datetime", "comment" => "Receiving date"],
"activity" => ["type" => "mediumtext", "comment" => "The JSON activity"],
"signer" => ["type" => "varchar(255)", "comment" => ""],
- "push" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
+ "push" => ["type" => "boolean", "comment" => "Is the entry pushed or have pulled it?"],
+ "trust" => ["type" => "boolean", "comment" => "Do we trust this entry?"],
"wid" => ["type" => "int unsigned", "foreign" => ["workerqueue" => "id"], "comment" => "Workerqueue id"], ],
"indexes" => [
"PRIMARY" => ["id"],