| | |
| | | class EmailDigests |
| | | { |
| | | protected string $campaign; |
| | | protected Cache $terms; |
| | | protected Cache $users; |
| | | protected CustomTable $userIndex; |
| | | protected CustomTable $termIndex; |
| | | public function __construct() |
| | |
| | | protected function registerUserIndex():void |
| | | { |
| | | $table = CustomTable::for('user_notification_email_digest'); |
| | | // $types = implode(',',array_map(function($item) { return "'{$item}'"; }, Registrar::getFeatured('favouritable'))); |
| | | // $types = implode(',',array_map(function($item) { return "'{$item}'"; }, Registrar::withFeature('favouritable'))); |
| | | $table->setColumns([ |
| | | 'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT', |
| | | 'user_id' => "{$table->getUserIDType()} NOT NULL", |
| | |
| | | protected function registerTermIndex():void |
| | | { |
| | | $table = CustomTable::for('user_notification_email_digest'); |
| | | $types = implode(',',array_map(function($item) { return "'{$item}'"; }, Registrar::getFeatured('favouritable', 'term'))); |
| | | $types = implode(',',array_map(function($item) { return "'{$item}'"; }, Registrar::withFeature('favouritable', 'term'))); |
| | | $table->setColumns([ |
| | | 'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT', |
| | | 'term_id' => "{$table->getTermIDType()} NOT NULL", |
| | |
| | | $content = ''; |
| | | foreach ($subscription as $item) { |
| | | $temp = match ($item['item_type']) { |
| | | array_merge(['user'], Registrar::getFeatured('favouritable', 'user')) => $this->getUserUpdates($item['item_id'], $frequency), |
| | | Registrar::getFeatured('favouritable', 'term') => $this->getTermUpdates($item['item_id'], $item['item_type'], $frequency), |
| | | array_merge(['user'], Registrar::withFeature('favouritable', 'user')) => $this->getUserUpdates($item['item_id'], $frequency), |
| | | Registrar::withFeature('favouritable', 'term') => $this->getTermUpdates($item['item_id'], $item['item_type'], $frequency), |
| | | default => false, |
| | | }; |
| | | if ($temp) { |