+ /**
+ * Report a user
+ *
+ * @param array $activity
+ * @return void
+ * @throws \Exception
+ */
+ public static function ReportAccount(array $activity)
+ {
+ $account_id = Contact::getIdForURL($activity['object_id']);
+ if (empty($account_id)) {
+ Logger::info('Unknown account', ['activity' => $activity]);
+ Queue::remove($activity);
+ return;
+ }
+
+ $reporter_id = Contact::getIdForURL($activity['actor']);
+ if (empty($reporter_id)) {
+ Logger::info('Unknown actor', ['activity' => $activity]);
+ Queue::remove($activity);
+ return;
+ }
+
+ $uri_ids = [];
+ foreach ($activity['object_ids'] as $status_id) {
+ $post = Post::selectFirst(['uri-id'], ['uri' => $status_id]);
+ if (!empty($post['uri-id'])) {
+ $uri_ids[] = $post['uri-id'];
+ }
+ }
+
+ $report = DI::reportFactory()->createFromReportsRequest($reporter_id, $account_id, $activity['content'], null, '', false, $uri_ids);
+ DI::report()->save($report);
+
+ Logger::info('Stored report', ['reporter' => $reporter_id, 'account_id' => $account_id, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]);
+ }
+