]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
* only send the one invitation reminder per email address, regardless of how many...
authorZach Copley <zach@status.net>
Tue, 21 Jun 2011 20:25:05 +0000 (13:25 -0700)
committerZach Copley <zach@status.net>
Tue, 21 Jun 2011 20:25:05 +0000 (13:25 -0700)
* don't send invitations converted invitations
* better error checking
* more logging

plugins/EmailReminder/EmailReminderPlugin.php
plugins/EmailReminder/lib/siteconfirmreminderhandler.php
plugins/EmailReminder/lib/userconfirmregreminderhandler.php
plugins/EmailReminder/lib/userinvitereminderhandler.php
plugins/EmailReminder/scripts/sendemailreminder.php

index 815537c659f18e4051923f1b122876caca6f89c6..72583f53492a574e51b308cb06df980304cf07ca 100644 (file)
@@ -135,6 +135,11 @@ class EmailReminderPlugin extends Plugin
         if (self::sendReminderEmail($type, $object, $subject, $title)) {
             try {
                 Email_reminder::recordReminder($type, $object, $day);
+                common_log(
+                    LOG_INFO,
+                    "Sent {$type} reminder to {$object->address}.",
+                    __FILE__
+                );
             } catch (Exception $e) {
                 // oh noez
                 common_log(LOG_ERR, $e->getMessage(), __FILE__);
index d75c40f5300f2eee46900a1cbf077ad367abc3e7..e5b4a5e2ab71848e40b30bc20b1bb0e8687630cf 100644 (file)
@@ -86,7 +86,9 @@ class SiteConfirmReminderHandler extends QueueHandler
                 break;
             case UserInviteReminderHandler::INVITE_REMINDER:
                 $invitation = new Invitation();
-                $invitation->find();
+                // Only send one reminder (the latest one), regardless of how many invitations a user has
+                $sql = 'SELECT * FROM (SELECT * FROM invitation WHERE registered_user_id IS NULL ORDER BY created DESC) invitees GROUP BY invitees.address';
+                $invitation->query($sql);
                 while ($invitation->fetch()) {
                     try {
                         $qm->enqueue(array($invitation, $opts), 'uinvrem');
index 89dad0e424cca7c66d6184f3a0e8a21594069902..1ea57aa6dbe76e55e82ab3de18e5c011e992caf6 100644 (file)
@@ -141,6 +141,9 @@ class UserConfirmRegReminderHandler extends UserReminderHandler {
                 return true;
             }
             break;
+        default:
+            common_log(LOG_INFO, "No need to send registration reminder to {$confirm->address}.", __FILE__);
+            break;
         }
         return true;
     }
index cb19a1fe783ccfeada253374e6bd97a7b7b4e73d..38c84f18bb42e2e370eba505569a83d615ec4eb2 100644 (file)
@@ -124,6 +124,9 @@ class UserInviteReminderHandler extends UserReminderHandler {
                     return true;
                 }
             break;
+        default:
+            common_log(LOG_INFO, "No need to send invitation reminder to {$invitation->address}.", __FILE__);
+            break;
         }
         return true;
     }
index 4bfa811e1014faafc948253919b75e59a70d7877..2cc214a671c04e11bd874563099e3f0f0029e59d 100644 (file)
@@ -90,19 +90,32 @@ case 'all':
 
 if (have_option('u', 'universe')) {
     $sn = new Status_network();
-    if ($sn->find()) {
-        while ($sn->fetch()) {
-            $server = $sn->getServerName();
-            StatusNet::init($server);
-            // Different queue manager, maybe!
-            $qm = QueueManager::get();
-            foreach ($reminders as $reminder) {
-                extract($reminder);
-                $qm->enqueue(array($type, $opts), 'siterem');
-                if (!$quiet) { print "Sent pending {$type} reminders for {$server}.\n"; }
+    try {
+        if ($sn->find()) {
+            while ($sn->fetch()) {
+                try {
+                    $server = $sn->getServerName();
+                    StatusNet::init($server);
+                    // Different queue manager, maybe!
+                    $qm = QueueManager::get();
+                    foreach ($reminders as $reminder) {
+                        extract($reminder);
+                        $qm->enqueue(array($type, $opts), 'siterem');
+                        if (!$quiet) { print "Sent pending {$type} reminders for {$server}.\n"; }
+                    }
+                } catch (Exception $e) {
+                    // keep going
+                    common_log(LOG_ERR, "Couldn't init {$server}.\n", __FILE__);
+                    if (!$quiet) { print "Couldn't init {$server}.\n"; }
+                    continue;
+                }
             }
+           if (!$quiet) { print "Done! Reminders sent to all unconfirmed addresses in the known universe.\n"; }
         }
-       if (!$quiet) { print "Done! Reminders sent to all unconfirmed addresses in the known universe.\n"; }
+    } catch (Exception $e) {
+        if (!$quiet) { print $e->getMessage() . "\n"; }
+        common_log(LOG_ERR, $e->getMessage(), __FILE__);
+        exit(1);
     }
 } else {
     $qm = QueueManager::get();