[tor-commits] [donate/master] Added Lektor error pages for Civi mailing links

peterh at torproject.org peterh at torproject.org
Tue May 11 21:17:51 UTC 2021


commit b4056e56f8186dbefd57c1da41a19a48ddbb5326
Author: Peter Haight <peterh at giantrabbit.com>
Date:   Mon Sep 28 16:33:52 2020 -0700

    Added Lektor error pages for Civi mailing links
    
    If a user clicks on a link like an optout or unsubscribe link in a
    CiviCRM mailing and then there's some issue with the unsubscribe, we
    need to show them some errors, so we need to send them back to the
    lektor site because we aren't going to have any display pages on the
    donate site once the Lektor pages go live.
    
    Issue #48285
---
 src/CivicrmMailingController.php | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/CivicrmMailingController.php b/src/CivicrmMailingController.php
index 4d6a51c2..1f54a6ae 100644
--- a/src/CivicrmMailingController.php
+++ b/src/CivicrmMailingController.php
@@ -32,11 +32,18 @@ class CivicrmMailingController extends BaseController {
       $crmController->sendMessage('Tor\Mailing\SubscriptionChange', $messageInfo);
       $this->renderer->render($response, "{$method}.twig");
     } else {
-      $this->vars = array(
-        'errors' => $errors,
-        'langcode' => $request->getAttribute('language')
-      );
-      $this->renderer->render($response, 'error.twig', $this->vars);
+      $subscriptionErrorUrl = $this->container->get('settings')->get('civiMailingErrorUrl');
+      if ($subscriptionErrorUrl === NULL) {
+        $this->vars = array(
+          'errors' => $errors,
+          'langcode' => $request->getAttribute('language')
+        );
+        $this->renderer->render($response, 'error.twig', $this->vars);
+      } else {
+        $uri = Uri::createFromString($subscriptionErrorUrl);
+        $uri->addQueryParam('errors', json_encode($errors));
+        return $response->withRedirect($uri->toString());
+      }
     }
   }
 }





More information about the tor-commits mailing list