]> git.mxchange.org Git - friendica-addons.git/commitdiff
[advancedcontentfilter] Clear rule cache anytime rules are changed in the database
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 16 Aug 2021 10:10:34 +0000 (06:10 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 16 Aug 2021 10:10:34 +0000 (06:10 -0400)
- This was preventing updated rules from being applied immediately as the cached rules were still in effect

advancedcontentfilter/advancedcontentfilter.php

index f5a341fedc4aa76b34d534e0852ec226bf1713e4..57c87ffd96c9e9fa8804075b84a5d04c41524e24 100644 (file)
@@ -361,6 +361,8 @@ function advancedcontentfilter_post_rules(ServerRequestInterface $request)
 
        $rule = DBA::selectFirst('advancedcontentfilter_rules', [], ['id' => DBA::lastInsertId()]);
 
+       DI::cache()->delete('rules_' . local_user());
+
        return json_encode(['message' => DI::l10n()->t('Rule successfully added'), 'rule' => $rule]);
 }
 
@@ -390,6 +392,8 @@ function advancedcontentfilter_put_rules_id(ServerRequestInterface $request, Res
                throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
        }
 
+       DI::cache()->delete('rules_' . local_user());
+
        return json_encode(['message' => DI::l10n()->t('Rule successfully updated')]);
 }
 
@@ -411,6 +415,8 @@ function advancedcontentfilter_delete_rules_id(ServerRequestInterface $request,
                throw new HTTPException\ServiceUnavailableException(DBA::errorMessage());
        }
 
+       DI::cache()->delete('rules_' . local_user());
+
        return json_encode(['message' => DI::l10n()->t('Rule successfully deleted')]);
 }