+ * Fetches the object type for a given object id
+ *
+ * @param array $activity
+ * @param string $object_id Object ID of the the provided object
+ *
+ * @return string with object type
+ */
+ private static function fetchObjectType($activity, $object_id)
+ {
+
+ $object_type = JsonLD::fetchElement($activity['as:object'], '@type');
+ if (!empty($object_type)) {
+ return $object_type;
+ }
+
+ if (Item::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
+ // We just assume "note" since it doesn't make a difference for the further processing
+ return 'as:Note';
+ }
+
+ $profile = APContact::getByURL($object_id);
+ if (!empty($profile['type'])) {
+ return 'as:' . $profile['type'];
+ }
+
+ $data = ActivityPub::fetchContent($object_id);
+ if (!empty($data)) {
+ $object = JsonLD::compact($data);
+ $type = JsonLD::fetchElement($object, '@type');
+ if (!empty($type)) {
+ return $type;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Prepare the object array