Add missing Mailing Events to API4: Delivered, Forward, Reply
authorlarssandergreen <lars@wildsight.ca>
Fri, 30 Jun 2023 00:25:41 +0000 (18:25 -0600)
committerlarssandergreen <lars@wildsight.ca>
Fri, 30 Jun 2023 00:25:41 +0000 (18:25 -0600)
CRM/Mailing/Event/BAO/MailingEventDelivered.php
CRM/Mailing/Event/BAO/MailingEventForward.php
ext/civi_mail/Civi/Api4/MailingEventDelivered.php [new file with mode: 0644]
ext/civi_mail/Civi/Api4/MailingEventForward.php [new file with mode: 0644]
ext/civi_mail/Civi/Api4/MailingEventReply.php [new file with mode: 0644]

index 6d823e71e3785a2609f5dc4e4c163f22106a7587..0d651c1fe7a369a4dd7f2aa67684c2f1016c1903 100644 (file)
 class CRM_Mailing_Event_BAO_MailingEventDelivered extends CRM_Mailing_Event_DAO_MailingEventDelivered {
 
   /**
-   * Create a new delivery event.
+   * Record a new delivery event.
    *
    * @param array $params
    *   Associative array of delivery event values.
    *
    * @return \CRM_Mailing_Event_BAO_MailingEventDelivered
    */
-  public static function &create(&$params) {
-    $q = &CRM_Mailing_Event_BAO_MailingEventQueue::verify($params['job_id'],
+  public static function recordDelivery(&$params) {
+    $q = CRM_Mailing_Event_BAO_MailingEventQueue::verify($params['job_id'],
       $params['event_queue_id'],
       $params['hash']
     );
@@ -54,6 +54,19 @@ class CRM_Mailing_Event_BAO_MailingEventDelivered extends CRM_Mailing_Event_DAO_
     return $delivered;
   }
 
+  /**
+   * Create function was renamed `recordDelivery` because it's not a standard CRUD create function
+   *
+   * @param array $params
+   * @deprecated
+   *
+   * @return \CRM_Mailing_Event_BAO_MailingEventDelivered
+   */
+  public static function create(&$params) {
+    CRM_Core_Error::deprecatedFunctionWarning('recordDelivery');
+    return self::recordDelivery($params);
+  }
+
   /**
    * Get row count for the event selector.
    *
index a94fcab29ad88ead39216832e771d7146219b718..b626eccafb1ecec8aac564486df4b27f98fbbd54 100644 (file)
@@ -183,7 +183,7 @@ class CRM_Mailing_Event_BAO_MailingEventForward extends CRM_Mailing_Event_DAO_Ma
       $successfulForward = TRUE;
       // Register the delivery event.
 
-      CRM_Mailing_Event_BAO_MailingEventDelivered::create($params);
+      CRM_Mailing_Event_BAO_MailingEventDelivered::recordDelivery($params);
     }
 
     $transaction->commit();
diff --git a/ext/civi_mail/Civi/Api4/MailingEventDelivered.php b/ext/civi_mail/Civi/Api4/MailingEventDelivered.php
new file mode 100644 (file)
index 0000000..08d38df
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+namespace Civi\Api4;
+
+/**
+ * Tracks when a queued email is actually delivered to the MTA.
+ *
+ * @see \Civi\Api4\Mailing
+ * @since 5.64
+ * @package Civi\Api4
+ */
+class MailingEventDelivered extends Generic\DAOEntity {
+  use Generic\Traits\ReadOnlyEntity;
+
+}
diff --git a/ext/civi_mail/Civi/Api4/MailingEventForward.php b/ext/civi_mail/Civi/Api4/MailingEventForward.php
new file mode 100644 (file)
index 0000000..9459c4d
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+namespace Civi\Api4;
+
+/**
+ * Tracks when a contact forwards a mailing to a (new) contact
+ *
+ * @see \Civi\Api4\Mailing
+ * @since 5.64
+ * @package Civi\Api4
+ */
+class MailingEventForward extends Generic\DAOEntity {
+  use Generic\Traits\ReadOnlyEntity;
+
+}
diff --git a/ext/civi_mail/Civi/Api4/MailingEventReply.php b/ext/civi_mail/Civi/Api4/MailingEventReply.php
new file mode 100644 (file)
index 0000000..d21b1c5
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+namespace Civi\Api4;
+
+/**
+ * TTracks when a contact replies to a mailing.
+ *
+ * @see \Civi\Api4\Mailing
+ * @since 5.64
+ * @package Civi\Api4
+ */
+class MailingEventReply extends Generic\DAOEntity {
+  use Generic\Traits\ReadOnlyEntity;
+
+}