cachePrefix . 'blocked_domains'; if (!($found = cache($cacheName))) { $found = $this->findAll(); cache()->save($cacheName, $found, DECADE); } return $found; } public function isDomainBlocked($domain) { $hashedDomain = md5($domain); $cacheName = config('ActivityPub')->cachePrefix . "domain#{$hashedDomain}_isBlocked"; if (!($found = cache($cacheName))) { $found = (bool) $this->find($domain); cache()->save($cacheName, $found, DECADE); } return $found; } public function blockDomain($name) { $hashedDomain = md5($name); $prefix = config('ActivityPub')->cachePrefix; cache()->delete($prefix . "domain#{$hashedDomain}_isBlocked"); cache()->delete($prefix . 'blocked_domains'); cache()->deleteMatching($prefix . '*replies'); Events::trigger('on_block_domain', $name); $this->db->transStart(); // set all actors from the domain as blocked model('ActorModel') ->where('domain', $name) ->set('is_blocked', 1) ->update(); $result = $this->insert([ 'name' => $name, ]); $this->db->transComplete(); return $result; } /** * @return bool|BaseResult */ public function unblockDomain($name) { $hashedDomain = md5($name); $prefix = config('ActivityPub')->cachePrefix; cache()->delete($prefix . "domain#{$hashedDomain}_isBlocked"); cache()->delete($prefix . 'blocked_domains'); cache()->deleteMatching($prefix . '*replies'); Events::trigger('on_unblock_domain', $name); $this->db->transStart(); // unblock all actors from the domain model('ActorModel') ->where('domain', $name) ->set('is_blocked', 0) ->update(); $result = $this->delete($name); $this->db->transComplete(); return $result; } }