. // }}} /** * ActivityPub implementation for GNU social * * @package GNUsocial * @category ActivityPub * * @author Diogo Peralta Cordeiro <@diogo.site> * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\ActivityPub\Util\Model; use ActivityPhp\Type\AbstractObject; use Exception; use InvalidArgumentException; use Plugin\ActivityPub\Entity\ActivitypubActivity; /** * This class handles translation between JSON and ActivityPub Announces * * @copyright 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ class ActivityAnnounce extends Activity { protected static function handle_core_activity(\App\Entity\Actor $actor, AbstractObject $type_activity, mixed $type_object, ?ActivitypubActivity &$ap_act): ActivitypubActivity { // The only core Announce we recognise is for (transient) activities coming from Group actors if ($actor->isGroup()) { if ($type_object instanceof AbstractObject) { return $ap_act = Activity::fromJson($type_object); } else { throw new Exception('Already handled.'); } } else { throw new InvalidArgumentException('Unsupported Announce Activity.'); } } }