Skip to content
Snippets Groups Projects
ActivityModel.php 2.55 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * @copyright  2021 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    namespace ActivityPub\Models;
    
    
    use CodeIgniter\Database\BaseResult;
    
    class ActivityModel extends UuidModel
    {
    
        protected $table = 'activitypub_activities';
    
        protected $uuidFields = ['id', 'status_id'];
    
        protected $allowedFields = [
            'id',
            'actor_id',
            'target_actor_id',
    
        /**
         * @var string
         */
        protected $returnType = Activity::class;
    
        public function getActivityById(string $activityId): ?Activity
    
                config('ActivityPub')
                    ->cachePrefix . "activity#{$activityId}";
            if (! ($found = cache($cacheName))) {
    
                cache()
                    ->save($cacheName, $found, DECADE);
    
        }
    
        /**
         * Inserts a new activity record in the database
         *
    
            string $payload,
            DateTimeInterface $scheduledAt = null,
    
            ?string $taskStatus = null
    
        ): BaseResult | int | string | false {
    
            return $this->insert(
                [
                    'actor_id' => $actorId,
                    'target_actor_id' => $targetActorId,
    
                    'status_id' => $statusId,
    
                    'type' => $type,
                    'payload' => $payload,
                    'scheduled_at' => $scheduledAt,
    
                    'task_status' => $taskStatus,
    
         */
        public function getScheduledActivities(): array
    
        {
            return $this->where('`scheduled_at` <= NOW()', null, false)
    
                ->orderBy('scheduled_at', 'ASC')
                ->findAll();
        }
    }