setId($article->getId()) ->setURL($article->getURL()); $note->setContent($article->getContent()); $note->setSummary($article->getSummary()); $note->setPublished($article->getPublished()); $note->setName($article->getName()); $note->setAttributedTo($article->getAttributedTo()); foreach ($article->getTo() as $to) { $note->addTo($to); } foreach ($article->getCc() as $cc) { $note->addCc($cc); } return $note; } /** Conditionally convert article to a note * * @param \Federator\Data\ActivityPub\Common\Article $article * @param string $targetUrl * The target URL for the activity (e.g. mastodon.social) * @return \Federator\Data\ActivityPub\Common\Note|\Federator\Data\ActivityPub\Common\Article * The generated note on success, false on failure */ public static function conditionalConvertToNote($article, $targetUrl) { $supportFile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '../formatsupport.json'); if ($supportFile === false) { error_log("Article::conditionalConvertToNote Failed to read support file for article conversion."); return $article; // Fallback to original article if file read fails } $supportlist = json_decode($supportFile, true); if (!isset($supportlist['activitypub']['article']) || !is_array($supportlist['activitypub']['article']) || !in_array($targetUrl, $supportlist['activitypub']['article'], true) ) { return self::convertToNote($article); // Articles are not supported for this target } return $article; // Articles are supported, return as is } }