aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2020-04-26 15:39:57 +0200
committerGitHub <noreply@github.com>2020-04-26 15:39:57 +0200
commit0e8a0f77d0b643a884e6687bd9c463267852a970 (patch)
tree88c6761b4215637bba34b263015e87750c92a187 /app
parent8a8a78a64c116caf81aaa4339906298bdc0e32e0 (diff)
parent71f7e58fbd84e1d15c7a405a3c5872adb937dc37 (diff)
downloadwallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.gz
wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.tar.zst
wallabag-0e8a0f77d0b643a884e6687bd9c463267852a970.zip
Merge pull request #4026 from wallabag/3760-ignorelist-db
Move Ignore Origin rules to database
Diffstat (limited to 'app')
-rw-r--r--app/DoctrineMigrations/Version20190826204730.php64
-rw-r--r--app/config/security.yml1
-rw-r--r--app/config/wallabag.yml8
3 files changed, 73 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20190826204730.php b/app/DoctrineMigrations/Version20190826204730.php
new file mode 100644
index 00000000..ee1ba6bf
--- /dev/null
+++ b/app/DoctrineMigrations/Version20190826204730.php
@@ -0,0 +1,64 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Application\Migrations;
6
7use Doctrine\DBAL\Schema\Schema;
8use Wallabag\CoreBundle\Doctrine\WallabagMigration;
9
10/**
11 * Add tables for the ignore origin rules.
12 */
13final class Version20190826204730 extends WallabagMigration
14{
15 public function up(Schema $schema): void
16 {
17 if (false === $schema->hasTable($this->getTable('ignore_origin_user_rule'))) {
18 $userTable = $schema->createTable($this->getTable('ignore_origin_user_rule', true));
19 $userTable->addColumn('id', 'integer', ['autoincrement' => true]);
20 $userTable->addColumn('config_id', 'integer');
21 $userTable->addColumn('rule', 'string', ['length' => 255]);
22 $userTable->addIndex(['config_id'], 'idx_config');
23 $userTable->setPrimaryKey(['id']);
24 $userTable->addForeignKeyConstraint($this->getTable('config'), ['config_id'], ['id'], [], 'fk_config');
25
26 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
27 $schema->dropSequence('ignore_origin_user_rule_id_seq');
28 $schema->createSequence('ignore_origin_user_rule_id_seq');
29 }
30 }
31
32 if (false === $schema->hasTable($this->getTable('ignore_origin_instance_rule'))) {
33 $instanceTable = $schema->createTable($this->getTable('ignore_origin_instance_rule', true));
34 $instanceTable->addColumn('id', 'integer', ['autoincrement' => true]);
35 $instanceTable->addColumn('rule', 'string', ['length' => 255]);
36 $instanceTable->setPrimaryKey(['id']);
37
38 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
39 $schema->dropSequence('ignore_origin_instance_rule_id_seq');
40 $schema->createSequence('ignore_origin_instance_rule_id_seq');
41 }
42 }
43 }
44
45 public function postUp(Schema $schema): void
46 {
47 foreach ($this->container->getParameter('wallabag_core.default_ignore_origin_instance_rules') as $entity) {
48 $previous_rule = $this->container
49 ->get('doctrine.orm.default_entity_manager')
50 ->getConnection()
51 ->fetchArray('SELECT * FROM ' . $this->getTable('ignore_origin_instance_rule') . " WHERE rule = '" . $entity['rule'] . "'");
52
53 if (false === $previous_rule) {
54 $this->addSql('INSERT INTO ' . $this->getTable('ignore_origin_instance_rule') . " (rule) VALUES ('" . $entity['rule'] . "');");
55 }
56 }
57 }
58
59 public function down(Schema $schema): void
60 {
61 $schema->dropTable($this->getTable('ignore_origin_user_rule'));
62 $schema->dropTable($this->getTable('ignore_origin_instance_rule'));
63 }
64}
diff --git a/app/config/security.yml b/app/config/security.yml
index 760b2550..5a73440b 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -79,4 +79,5 @@ security:
79 - { path: ^/annotations, roles: ROLE_USER } 79 - { path: ^/annotations, roles: ROLE_USER }
80 - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS } 80 - { path: ^/2fa, role: IS_AUTHENTICATED_2FA_IN_PROGRESS }
81 - { path: ^/users, roles: ROLE_SUPER_ADMIN } 81 - { path: ^/users, roles: ROLE_SUPER_ADMIN }
82 - { path: ^/ignore-origin-instance-rules, roles: ROLE_SUPER_ADMIN }
82 - { path: ^/, roles: ROLE_USER } 83 - { path: ^/, roles: ROLE_USER }
diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml
index eaa92507..4dad9200 100644
--- a/app/config/wallabag.yml
+++ b/app/config/wallabag.yml
@@ -165,6 +165,14 @@ wallabag_core:
165 value: 0 165 value: 0
166 section: entry 166 section: entry
167 167
168 default_ignore_origin_instance_rules:
169 -
170 rule: host = "feedproxy.google.com"
171 -
172 rule: host = "feeds.reuters.com"
173 -
174 rule: _all ~ "https?://www\.lemonde\.fr/tiny.*"
175
168wallabag_user: 176wallabag_user:
169 registration_enabled: "%fosuser_registration%" 177 registration_enabled: "%fosuser_registration%"
170 178