+ /**
+ * Stores unhandled or unknown Activities as a file
+ *
+ * @param boolean $unknown "true" if the activity is unknown, "false" if it is unhandled
+ * @param string $type Activity type
+ * @param array $object_data Preprocessed array that is generated out of the received activity
+ * @param array $activity Array with activity data
+ * @param string $body The unprocessed 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
+ * @param array $signer The signer of the post
+ * @return void
+ */
+ private static function storeUnhandledActivity(bool $unknown, string $type, array $object_data, array $activity, string $body = '', int $uid = null, bool $trust_source = false, bool $push = false, array $signer = [])
+ {
+ if (!DI::config()->get('debug', 'ap_log_unknown')) {
+ return;
+ }
+
+ $file = ($unknown ? 'unknown-' : 'unhandled-') . str_replace(':', '-', $type) . '-';
+
+ if (!empty($object_data['object_type'])) {
+ $file .= str_replace(':', '-', $object_data['object_type']) . '-';
+ }
+
+ if (!empty($object_data['object_object_type'])) {
+ $file .= str_replace(':', '-', $object_data['object_object_type']) . '-';
+ }
+
+ $tempfile = tempnam(System::getTempPath(), $file);
+ file_put_contents($tempfile, json_encode(['activity' => $activity, 'body' => $body, 'uid' => $uid, 'trust_source' => $trust_source, 'push' => $push, 'signer' => $signer, 'object_data' => $object_data], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+ Logger::notice('Unknown activity stored', ['type' => $type, 'object_type' => $object_data['object_type'], $object_data['object_object_type'] ?? '', 'file' => $tempfile]);
+ }
+